<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>开分单</title>
    <% include("/common/common_css_js.html"){} %>
    <script type="text/javascript" src="http://static.runoob.com/assets/qrcode/qrcode.min.js"></script>
    <script type="text/javascript" src="${base!}/js/LodopFuncs.js?d=${jdate!}"></script>
    <style type="text/css">
        .align-right{
            display: flex;
            flex-direction: row;
            justify-content: flex-end;
            align-items: center;
            width: 100%;
            padding-bottom: 5px;
        }

        .border{
            border: 1px solid black;
        }


        .item
        {
            float:left;
            width:400px;
            height:200px;
            margin-left:4px;
            margin-top:4px;
        }

        .flexcolumn{
            display: flex;
            flex-direction: column;
        }

        .flexrow{
            display: flex;
            flex-direction: row;
        }

        .center{
            justify-content: center;
            align-items: center;
        }

        .width100{
            width: 100%;
        }

        .width50{
            width: 50%;
        }

        .mgleft10{
            margin-left: 10px;
        }
        .mgright10{
            margin-right: 10px;
        }

        .fontsize8{
            font-size: 8pt;
        }

        .fontsize10{
            font-size: 10pt;
        }

        .fontsize15{
            font-size: 15pt;
        }

        .fontsize20{
            font-size: 20pt;
        }

        .height30{
            height: 30px;
        }

        .height45{
            height: 45px;
        }



    </style>

</head>
<body>
    <object style="display: none" id="LODOP" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
        <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
    </object>

    <div style="width: 1000px;margin: 5px 0px;margin-left: 5px;">

        <% if(so.hasPermission("bNativeBill:add")){%>
            <a id="addBtn" class="mini-button" iconCls="icon-save" onclick="saveBill(false)">添加</a>
        <% } %>

        <% if(so.hasPermission("bNativeBill:save")){%>
            <a id="updateBtn" class="mini-button" iconCls="icon-save" onclick="saveBill(false)">保存</a>
        <% } %>

        <% if(so.hasPermission("bNativeBill:non-priceUpdate")){%>
            <a id="updateSaveBtn" class="mini-button" iconCls="icon-ok" onclick="saveBill(true)">非价格信息更新</a>
        <% } %>


        <% if(so.hasPermission("bNativeBill:print")){%>
            <span class="separator"></span>
            <a class="mini-button" iconCls="icon-print" onclick="showPrintBill()">打印</a>
        <% } %>

        <% if(so.hasPermission("bNativeBill:labelPrint")){%>
            <a class="mini-button" iconCls="icon-print" onclick="showPrintLabel()">标签打印</a>
        <% } %>
    </div>

    <div id="billForm" style="padding-bottom: 5px;" class="mini-fit">
        <span>分单号:</span><input id="id" name="id" emptyText="请输入分单号"  class="mini-textbox" selectOnFocus="true" required="true" requiredErrorText="分单号不能为空" onvaluechanged="idChange"/>
        <span>分单归属部门:</span>
        <input id="attributionDepartmentId" name="attributionDepartmentId" class="mini-treeselect" style="width:250px;" textField="name" valueField="id" emptyText="请选择..."
               expandOnLoad="3"  virtualScroll="true" enabled="false"
               required="true" allowInput="true" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择归属部门"/>
        <div style="margin-top: 5px"></div>
        <span>运输种类:</span><input id="transportSpeciesId" name="transportSpeciesId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                 required="true" allowInput="false" showNullItem="false" nullItemText="请选择..." requiredErrorText="没有选择运输种类" onvaluechanged="transportSpeciesIdChange" />
        <span>承运方式:</span><input id="transportWayId" name="transportWayId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                 required="true" allowInput="false" showNullItem="false" nullItemText="请选择..." requiredErrorText="没有选择承运方式"/>
        <span>运输范围:</span><input id="transportScopeId" name="transportScopeId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                 required="true" allowInput="false" showNullItem="false" nullItemText="请选择..." requiredErrorText="没有选择运输范围"/>
        <span>营业部所在城市:</span><input id="cityId" name="cityId"  class="mini-hidden" required="true" />
        <input id="cityName" name="cityName" emptyText="营业部城市"  class="mini-textbox" required="true" enabled="false" requiredErrorText="营业部城市不能为空"/>

        <span>目的市:</span><input id="destCityId" name="destCityId" class="mini-treeselect"
                                   multiSelect="false" valueField="id" textField="name" parentField="pid" allowInput="true" valueFromSelect="true"  virtualScroll="true"
                                   style="width: 220px;" expandOnLoad="true" required="true" requiredErrorText="没有选择目的市" nullItemText="请选择..." onvaluechanged="destCityIdChange" />

        <div style="margin-top: 5px"></div>
        <span>发货人:</span>
        <div id="deliveryCustomerId" name="deliveryCustomerId"
             class="mini-combobox"
             style="width:400px;"
             popupWidth="800" textField="name" valueField="id"
             allowInput="true" required="true" requiredErrorText="发货人不能为空"
             emptyText="发货人名称" onvaluechanged="setDeliveryCustomer">
            <div property="columns">
                <div header="发货人名称" field="name"></div>
                <div header="发货人简称" field="shortName"></div>
                <div header="发货人电话" field="phone"></div>
                <div header="发货人地址" field="address"></div>
            </div>
        </div>

        <input id="deliveryCustomerName" name="deliveryCustomerName" class="mini-hidden" emptyText="发货人名称" required="true" enabled="false" requiredErrorText="发货人名称不能为空"/>
        <input id="deliveryCustomerPhone"  name="deliveryCustomerPhone" class="mini-textbox" emptyText="发货人电话"  style="width:150px;" selectOnFocus="true" required="true" enabled="false" requiredErrorText="发货人电话不能为空"/>
        <input id="deliveryCustomerAddress" name="deliveryCustomerAddress" class="mini-textbox" emptyText="发货人地址" style="width:400px;" selectOnFocus="true" required="true" enabled="false" requiredErrorText="发货人地址不能为空"/>
        <span class="separator"></span>
        <span>发货联系人:</span>
        <input id="deliveryCustomerContactId" name="deliveryCustomerContactId" class="mini-combobox"  style="width: 80px" selectOnFocus="true"
               textField="name" valueField="id" emptyText="请选择..." required="false" allowInput="false"
               showNullItem="true" nullItemText="请选择..." requiredErrorText="请选择发货人联系人"
               onvaluechanged="setContract"/>
        <input id="deliveryCustomerContactName" name="deliveryCustomerContactName" class="mini-hidden" enabled="false"/>
        <input id="deliveryCustomerContactPhone" name="deliveryCustomerContactPhone"  style="width: 100px" class="mini-textbox" selectOnFocus="true" enabled="false"/>
        <span class="separator"></span>
        <span>业务员:</span>
        <input id="deliveryCustomerSalemanId" name="deliveryCustomerSalemanId" class="mini-hidden" enabled="true"/>
        <input id="deliveryCustomerSalemanName" name="deliveryCustomerSalemanName" style="width: 100px" class="mini-textbox" selectOnFocus="true" enabled="false"/>

        <div style="margin-top: 5px"></div>
        <span>收货人:</span>
        <input id="receiveCustomerName" name="receiveCustomerName" style="width:400px;"  emptyText="收货人名称"  class="mini-textbox" selectOnFocus="true" required="true" enabled="false" requiredErrorText="收货人名称不能为空"/>
        <input id="receiveCustomerPhone" name="receiveCustomerPhone" style="width:150px;"  emptyText="收货人电话"  class="mini-textbox" selectOnFocus="true" required="true" enabled="false" requiredErrorText="收货人电话不能为空"/>
        <input id="receiveCustomerAddress" name="receiveCustomerAddress" style="width:400px;"  emptyText="收货人地址"  class="mini-textbox" selectOnFocus="true" required="true"  enabled="false" requiredErrorText="收货人地址不能为空"/>

        <a  class="mini-button" iconCls="icon-search" onclick="showReceiveCustomerPanel()" >选择收货人</a>

        <div style="margin-top: 5px"></div>

        <!-- url="${base}/pages/basic_data_manage/xt_pick_up_point/queryPickUpPointByCondition?cityId=" -->
        <span>提货点:</span>
        <div id="pickUpPointId" name="pickUpPointId" class="mini-combobox" style="width:400px;"  popupWidth="400" textField="name" valueField="id"
             required="true" requiredErrorText="提货点不能为空"
             allowInput="false"
             emptyText="提货点名称"
             onvaluechanged="setUpPointInfo">
            <div property="columns">
                <div header="提货点名称" field="name"></div>
                <div header="提货点电话" field="phone"></div>
                <div header="提货点地址" field="address"></div>
            </div>
        </div>
        <input id="pickUpPointName" name="pickUpPointName" style="width:400px;"  emptyText="提货点名称"  class="mini-textbox" selectOnFocus="true" visible="false"  required="false" requiredErrorText="提货点名称不能为空"/>
        <input id="pickUpPointPhone" name="pickUpPointPhone" style="width:150px;"  emptyText="提货点电话"  class="mini-textbox" selectOnFocus="true" required="true" requiredErrorText="提货点电话不能为空"/>
        <input id="pickUpPointAddress" name="pickUpPointAddress" style="width:400px;"  emptyText="提货点地址"  class="mini-textbox" selectOnFocus="true" required="true" requiredErrorText="提货点地址不能为空"/>

        <a id="btn1" class="mini-button" iconCls="icon-ok" onclick="equalReceiveCustomer(1)">同收货人</a>
        <a id="btn2" class="mini-button" iconCls="icon-ok" onclick="equalReceiveCustomer(2)" visible="false">提货点选择</a>

        <div style="margin-top: 5px"></div>
        <span>提货方式:</span><input id="pickUpGoodsWayId" name="pickUpGoodsWayId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                 required="true" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择提货方式"/>
        <span class="separator"></span>
        <span>签收方式:</span><input id="signChooseId" name="signChooseId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                 required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择签收方式"/>

        <span class="separator"></span>
        <!-- url="${base}/pages/basic_data_manage/xt_airport/queryAirPortByKey" -->
        <span id="startAirportSpan">始发机场:</span>
        <div id="airportId" name="airportId" class="mini-combobox" style="width:150px;"  popupWidth="1000" textField="name" valueField="id"
             required="true" requiredErrorText="始发机场不能为空"
             searchField="key"
             allowInput="true"
             onvaluechanged="airportIdValueChanged"
             emptyText="始发机场名称">
            <div property="columns">
                <div header="ID" field="id" width="30"></div>
                <div header="机场名称" field="name"></div>
                <div header="简称" field="shortName"></div>
            </div>
        </div>

        <span>班次日期:</span>
        <input id="flightDate" name="flightDate" class="mini-datepicker" style="width:150px;"  nullValue="null"
               format="yyyy-MM-dd"  showOkButton="true" showClearButton="true" required="true"
               onvaluechanged="onFlightDateValueChanged"/>

        <span>班次号:</span>
        <div id="flightNo" name="flightNo" class="mini-combobox" style="width:150px;"  popupWidth="400" textField="name" valueField="id"
             multiSelect="false"    oncloseclick="flightOnCloseClick" onvaluechanged="flightOnValueChange" >
            <div property="columns">
                <div header="航班" field="name"></div>
                <div header="起飞时间" field="planTakeOffTime"></div>
                <div header="航司" field="shortName"></div>
            </div>
        </div>
        <!-- 空运时班次号隐藏,同时设置其不是必须的，汽运时显示且是必填的 -->
        <input id="flightName" name="flightName" class="mini-textbox" emptyText="班次号名称" required="true"   requiredErrorText="班次号名称不能为空"/>
        <!-- 这是一个隐藏字段 -->
        <input id="airlinesId" name="airlinesId" class="mini-hidden" emptyText="航空公司" required="true" enabled="false" requiredErrorText="航空公司不能为空"/>
        <span>计划出发时间:</span>
        <input id="planTakeOffTime" name="planTakeOffTime" class="mini-textbox" emptyText="计划出发时间" style="width:100px;" selectOnFocus="true" required="true" enabled="false" requiredErrorText="计划出发时间不能为空"/>

        <div style="margin-top: 5px"></div>
        <span>货物名称:</span><input id="goodsName" name="goodsName" emptyText="货物名称"  class="mini-textbox" selectOnFocus="true" required="true" requiredErrorText="货物名称不能为空"/>
        <span class="separator"></span>
        <span>货物类型:</span><input id="goodsTypeId" name="goodsTypeId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                 required="true" allowInput="false" showNullItem="false" nullItemText="请选择..." requiredErrorText="没有选择货物类型"/>
        <span class="separator"></span>
        <span>包装方式:</span><input id="packingWayId" name="packingWayId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                 required="true" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择包装方式"/>

        <div style="display: flex;justify-content: flex-start;width: 1400px;margin-top: 5px">
            <div style="display: flex;flex-direction: column">
                <div class="align-right">
                    <span>长:</span><input id="length" name="length" emptyText="长度"  class="mini-textbox" style="width: 100px;background-color: #c3cf9d" selectOnFocus="true" required="false" onvaluechanged="lengthChange"/>
                </div>
                <div class="align-right">
                    <span>宽:</span><input id="width" name="width" emptyText="宽度"  class="mini-textbox" style="width: 100px;background-color: #c3cf9d" selectOnFocus="true" required="false" onvaluechanged="widthChange"/>
                </div>
                <div class="align-right">
                    <span>高:</span><input id="height" name="height" emptyText="高度"  class="mini-textbox" style="width: 100px;background-color: #c3cf9d" selectOnFocus="true" required="false" onvaluechanged="heightChange"/>
                </div>
                <div class="align-right">
                    <span>件数:</span><input id="numberPackages" name="numberPackages" emptyText="件数"  class="mini-textbox" style="width: 100px;background-color: #c3cf9d" selectOnFocus="true" required="false" onvaluechanged="numberPackagesChange"/>
                </div>
                <div class="align-right">
                    <a class="mini-button" iconCls="icon-ok" onclick="calcVolume">计算</a>
                </div>
            </div>
            <div style="display: flex;flex-direction: column;margin-left: 5px;width: 300px">
                <span>物品信息:</span><textarea id="volumeInformation" name="volumeInformation" class="mini-textarea" selectOnFocus="true" style="width: 100%;height: 100px" emptyText="请输入物品信息"></textarea>
            </div>
            <div style="display: flex;flex-direction: column;margin-left: 10px;width: 200px">
                <div class="align-right">
                    <span>总件数:</span><input id="totalNumber" name="totalNumber" vtype="int" value="0" emptyText="总件数"  class="mini-textbox" style="width: 100px" selectOnFocus="true" required="true"  onvaluechanged="totalNumberChange" />
                </div>
                <div class="align-right">
                    <span>实际重量:</span><input id="actualWeight" name="actualWeight" vtype="float" value="0" emptyText="实际重量"  class="mini-textbox" style="width: 100px" selectOnFocus="true" required="true" onvaluechanged="actualWeightChange"/>
                </div>
                <div class="align-right">
                    <span>计费重量:</span><input id="chargeableWeight" name="chargeableWeight" vtype="float" value="0" emptyText="计费重量"  class="mini-textbox" style="width: 100px" selectOnFocus="true" required="true" onvaluechanged="chargeableWeightChange" />
                </div>
                <div class="align-right">
                    <span>体积:</span><input id="volume" name="volume" vtype="float" value="0" emptyText="体积"  class="mini-textbox" style="width: 100px" selectOnFocus="true" required="true" onvaluechanged="volumeChange" />
                </div>

            </div>

            <div style="display: flex;flex-direction: column;margin-left: 10px;width: 250px">
                <div class="align-right">
                    <span>重量费率:</span><input id="weightRate" name="weightRate" vtype="float" value="0" emptyText="重量费率"  class="mini-textbox" style="width: 100px" selectOnFocus="true" required="true" onvaluechanged="weightRateChange" />
                </div>
                <div class="align-right">
                    <span>体积费率:</span><input id="volumeRate" name="volumeRate" vtype="float" value="0" emptyText="体积费率"  class="mini-textbox" style="width: 100px" selectOnFocus="true" required="true" onvaluechanged="volumeRateChange" />
                </div>
                <div class="align-right">
                    <span>起票价:</span><input id="ticketPrice" name="ticketPrice" vtype="float" value="0" emptyText="起票价"  class="mini-textbox" style="width: 100px" selectOnFocus="true" required="true" onvaluechanged="ticketPriceChange" />
                </div>
                <div class="align-right">
                    <a class="mini-button" onclick="loadCustomerAgrement()">加载费率并计算运费</a>
                    <span class="separator"></span>
                    <a class="mini-button" onclick="showCustomerAgrement()">显示费率</a>
                </div>
                <div class="align-right">
                    <span>运费合计:</span><input id="transportCost" name="transportCost" vtype="float" value="0" emptyText="运费合计"  class="mini-textbox" style="width: 100px" selectOnFocus="true" required="true" enabled="false" onvaluechanged="transportCostChange"/>
                </div>
<!--                <div class="align-right">-->
<!--                    <a class="mini-button" iconCls="icon-ok" onclick="calcTransportCost()">计算</a>-->
<!--                </div>-->
            </div>
            <div style="display: flex;flex-direction: column;margin-left: 10px;width: 300px;">
                <div class="align-right">
                    <span>声明价值:</span><input id="declaredValue" name="declaredValue" vtype="float" value="2500" emptyText="声明价值"  class="mini-textbox" style="margin-right: 15px" selectOnFocus="true" required="true" requiredErrorText="声明价值不能为空" onvaluechanged="calcInsuranceFee"/>
                </div>
                <div class="align-right">
                    <span>保险费率:</span>
                    <input id="insuranceRate" name="insuranceRate" vtype="float" value="0" emptyText="保险费率"  class="mini-textbox" selectOnFocus="true" required="true" requiredErrorText="保险费率不能为空" onvaluechanged="calcInsuranceFee"/>
                    <span style="color: red">‰</span>
                </div>
                <div class="align-right">
                    <span>保费:</span><input id="insuranceFee" name="insuranceFee" vtype="float" value="0" emptyText="货物名称"  class="mini-textbox" style="margin-right: 15px" selectOnFocus="true" required="true" requiredErrorText="保费不能为空" enabled="false"/>
                </div>
            </div>
        </div>

        <div style="margin-top: 5px"></div>
        <span>开单送货费:</span><input id="openBillDeliveryCharge" name="openBillDeliveryCharge" vtype="float" value="0" emptyText="开单送货费"  class="mini-textbox" required="true" requiredErrorText="开单送货费不能为空" onvaluechanged="openBillDeliveryChargeChange"/>
        <span>代理送货费:</span><input id="agentDeliveryCharge" name="agentDeliveryCharge" vtype="float" value="0" emptyText="代理送货费"  class="mini-textbox" required="true" requiredErrorText="代理送货费不能为空" onvaluechanged="agentDeliveryChargeChange"/>
        <span>代收货款:</span><input id="collectionMoney" vtype="float" name="collectionMoney" value="0" emptyText="代收款"  class="mini-textbox" required="true" requiredErrorText="代收款不能为空" onvaluechanged="collectionMoneyChange"/>
        <span>税金:</span><input id="tax" name="tax" vtype="float" value="0" emptyText="税金"  class="mini-textbox" required="true" requiredErrorText="税金不能为空" onvaluechanged="taxChange"/>
        <span>燃油费:</span><input id="fuelSurcharge" vtype="float" name="fuelSurcharge" value="0" emptyText="燃油费"  class="mini-textbox" required="true" requiredErrorText="燃油费不能为空" onvaluechanged="fuelSurchargeChange"/>

        <div style="margin-top: 5px"></div>
        <span>送货费备注:</span>
        <input id="deliveryChargeComment" name="deliveryChargeComment" emptyText="送货费备注"  class="mini-textbox" style="width:400px" required="false" requiredErrorText="送货费备注不能为空"/>

        <span>提货费(付给提货司机):</span><input id="pickupDriverFee"  name="pickupDriverFee"  vtype="int" value="0" emptyText="提货费"  class="mini-textbox" required="false" requiredErrorText="提货费不能为空" />
        <span>提货人(司机):</span><input id="pickupDriverName"  name="pickupDriverName"  emptyText="提货人"  class="mini-textbox" required="false" requiredErrorText="提货人不能为空"/>

        <div style="margin-top: 5px"></div>
        <div style="display: flex;justify-content: flex-start;width: 1200px;">
            <div style="margin-top: 55px;">
                <span>其他费用:</span>
            </div>
            <div style="width: 5px"></div>
            <div style="width:600px;border-bottom:0;padding:0px;">
                <div class="mini-toolbar" style="width:600px;border-bottom:0;padding:0px;">
                    <a class="mini-button" iconCls="icon-add" onclick="addOtherChargesRow()" plain="true" tooltip="增加...">增加</a>
                    <span class="separator"></span>
                    <a class="mini-button" iconCls="icon-remove" onclick="removeOtherChargesRow()" plain="true" tooltip="删除...">删除</a>
                    <span class="separator"></span>
                    <a class="mini-button" iconCls="icon-ok" onclick="calcOtherCharges()" plain="true" tooltip="计算其他费用...">计算其他费用</a>
                </div>
                <div id="otherChargeDatagrid" class="mini-datagrid" style="width:600px;height:100px;"
                     idField="id"
                     showPager="false"
                     allowCellEdit="true" allowCellSelect="true" multiSelect="true"
                     editNextOnEnterKey="true"  editNextRowCell="true" >
                    <div property="columns">
                        <div type="checkcolumn"></div>
                        <div type="indexcolumn">序号</div>
                        <div name="name"  field="name" headerAlign="center" allowSort="true" width="150" >其他费用名目
                            <input property="editor" class="mini-textbox" style="width:100%;" minWidth="200" />
                        </div>
                        <div name ="amount" field="amount" width="100" allowSort="true" >金额
                            <input property="editor" class="mini-textbox"  value="0" style="width:100%;"/>
                        </div>
                        <div field="comment" width="120" headerAlign="center" allowSort="true">备注
                            <input property="editor" class="mini-textarea" style="width:200px;" minWidth="200" minHeight="50"/>
                        </div>
                    </div>
                </div>
            </div>
            <div style="width: 5px"></div>
            <div style="display: flex;flex-direction: column">
                <div style="display: flex;flex-direction: row;align-items:center;">
                    <span>金额:</span>
                    <input id="otherCharges" name="otherCharges" value="0" emptyText="其他费用"  class="mini-textbox" required="true" requiredErrorText="其他费用说明不能为空" enabled="false" vtype="float"/>
                </div>
                <div style="margin-top: 5px"></div>

                <span>其他费用说明:</span>
                <textarea id="otherChargesComment" name="otherChargesComment" class="mini-textarea" selectOnFocus="true" style="width: 500px;height: 75px" emptyText="其他费用说明" required="false" enabled="false"></textarea>

            </div>
        </div>

        <div style="margin-top: 5px"></div>
        <span>业务费:</span><input id="serviceCharge" name="serviceCharge" value="0" emptyText="业务费"  class="mini-textbox" selectOnFocus="true" required="true" requiredErrorText="业务费不能为空" onvaluechanged="serviceChargeChange" vtype="float"/>

        <span>业务费分摊类型:</span>
        <input id="businessCostAllocationTypeId" name="businessCostAllocationTypeId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
               required="true" allowInput="false" showNullItem="false" nullItemText="请选择..."  requiredErrorText="没有选择业务费分摊类型" onvaluechanged="serviceChargeShare" />
        <input id="businessCostAllocationId" name="businessCostAllocationId" value="12" emptyText="业务费用分摊类型"  class="mini-hidden" style="width: 100px" required="true" />
        <span>业务费备注:</span>
        <input id="businessCostComment" name="businessCostComment" emptyText="业务费用备注信息"  class="mini-textbox" style="width: 600px" selectOnFocus="true" required="false" />

<!--        <div style="margin-top: 5px"></div>-->
<!--        <span>实收运费:</span>-->
        <input id="actualTransportCost" name="actualTransportCost" value="0" emptyText="实收运费"  class="mini-hidden" selectOnFocus="true" style="width: 100px" required="true" enabled="false" />
<!--        <a class="mini-button" iconCls="icon-ok" onclick="calcActualTransportCost()">计算实收运费</a>-->
        <div style="margin-top: 5px"></div>
        <span>打单实际重量:</span><input id="printActualWeight" name="printActualWeight" vtype="float" value="0" emptyText="打单实际重量"  class="mini-textbox" style="width: 100px" required="true" />
        <span>打单计费重量:</span><input id="printChargeableWeight" name="printChargeableWeight" vtype="float" value="0" emptyText="打单计费重量"  class="mini-textbox" style="width: 100px" required="true" />
        <span>打单重量费率:</span><input id="printWeightRate" name="printWeightRate" vtype="float" value="0" emptyText="打单重量费率"  class="mini-textbox" style="width: 100px" required="true"  />
        <span>打单体积:</span><input id="printVolume" name="printVolume" vtype="float" value="0" emptyText="打单体积"  class="mini-textbox" style="width: 100px" required="true" />
        <span>打单体积费率:</span><input id="printVolumeRate" name="printVolumeRate" vtype="float" value="0" emptyText="打单体积费率"  class="mini-textbox" style="width: 100px" required="true"  />

        <!-- 内部操作费=分单的计费重量 * 0.2元/公斤(开单时默认填0，由操作设置模块选择后再计算得出，注意单价在页面上提供输入，不能直接固定为0.2) -->
        <input id="innerOperationCharge" name="innerOperationCharge" value="0" emptyText="内部操作费"  class="mini-hidden" style="width: 100px" required="true" enabled="false" />

        <div style="margin-top: 5px"></div>
        <span>发货人付款方式:</span><input id="deliveryCustomerPaymentMethodId" name="deliveryCustomerPaymentMethodId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                 required="true" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择发货人付款方式" onvaluechanged="deliveryCustomerPaymentMethodIdChange"/>
        <span>发货人付款金额:</span><input id="deliveryCustomerPaymentAmount" name="deliveryCustomerPaymentAmount" vtype="float" value="0" emptyText="发货人付款金额"  class="mini-textbox" selectOnFocus="true" required="true" requiredErrorText="发货人付款金额不能为空" onvaluechanged="deliveryCustomerPaymentAmountChange" vtype="float" />
        <span>收货人付款方式:</span><input id="receiveCustomerPaymentMethodId" name="receiveCustomerPaymentMethodId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                 required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择收货人付款方式" onvaluechanged="receiveCustomerPaymentMethodIdChange"/>
        <span>收货人付款金额:</span><input id="receiveCustomerPaymentAmount" name="receiveCustomerPaymentAmount" vtype="float" value="0" emptyText="收货人付款金额"  class="mini-textbox" selectOnFocus="true" required="true" requiredErrorText="收货人付款金额不能为空" onvaluechanged="receiveCustomerPaymentAmountChange" enabled="false" vtype="float"/>

        <div style="margin-top: 5px"></div>
        <span>总金额:</span><input id="totalAmount" name="totalAmount" vtype="float" value="0" emptyText="总金额"  class="mini-textbox" selectOnFocus="true" required="true" requiredErrorText="总金额不能为空"   />
        <span>实收金额:</span><input id="actualAmount" name="actualAmount" vtype="float" value="0" emptyText="实收金额"  class="mini-textbox" selectOnFocus="true" required="true" requiredErrorText="实收金额不能为空" />
        <span>拉货调整金额:</span><input id="dropAmount" name="dropAmount" value="0" vtype="float" emptyText="拉货调整金额"  class="mini-textbox" style="width: 100px" required="true" enabled="false" />
        <span>结算金额:</span><input id="settlementAmount" name="settlementAmount" value="0" vtype="float" emptyText="分单结算金额"  class="mini-textbox" style="width: 100px" required="true" enabled="false" />

        <div style="margin-top: 5px"></div>
<!--        <span>收银员:</span>-->
        <input id="cashierId" name="cashierId" class="mini-combobox" style="width:150px;display: none" textField="name" valueField="id" emptyText="请选择..."
                                required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择收银员" enabled="false" />

        <span>开单人:</span><input id="openBillUserId" name="openBillUserId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                required="true" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择开单人" enabled="false" />

        <span>开单日期:</span><input id="openBillDate" name="openBillDate" class="mini-datepicker" value="${openBillDate!}" style="width:200px;"  nullValue="null" format="yyyy-MM-dd"  showOkButton="true" showClearButton="true"/>

        <span>开单部门:</span><input id="openBillDepartmentId" name="openBillDepartmentId" class="mini-treeselect" style="width:250px;" textField="name" valueField="id" emptyText="请选择..."
                                 required="true" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择开单部门" enabled="false" />

        <span>点到部门:</span><input id="rollCallDepartmentId" name="rollCallDepartmentId" class="mini-treeselect" style="width:250px;" textField="name" valueField="id" emptyText="请选择..."
                                 required="true" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择点到部门" />
        <div style="margin-top: 5px"></div>
        <span>备注:</span><textarea id="comment" name="comment" class="mini-textarea" style="width: 80%;height: 50px" emptyText="请输入物品信息" selectOnFocus="true" required="false"></textarea>


        <!-- 默认值隐藏区域 -->
        <input id="billLoadStatusId" name="billLoadStatusId" value="351" emptyText="分单配载状态ID"  class="mini-hidden" style="width: 100px" required="true" enabled="false" />
        <input id="billLoadMasterBillIds" name="billLoadMasterBillIds" emptyText="分单关联主单号IDS"  class="mini-hidden" style="width: 100px" required="true" enabled="false" />
        <input id="businessCostStatusId" name="businessCostStatusId" value="321" emptyText="业务费状态ID"  class="mini-hidden" style="width: 100px" required="true" enabled="false" />
        <input id="agentDeliveryChargeStatusId" name="agentDeliveryChargeStatusId" value="321" emptyText="代理送货费状态ID"  class="mini-hidden" style="width: 100px" required="true" enabled="false" />
        <input id="arrearsStatusId" name="arrearsStatusId" value="321" emptyText="分单欠款状态ID"  class="mini-hidden" style="width: 100px" required="true" enabled="false" />

        <input id="dropStatusId" name="dropStatusId" value="361" emptyText="拉货状态ID"  class="mini-hidden"  required="true" enabled="false" />
        <input id="settlementStatusId" name="settlementStatusId" value="321" emptyText="分单结算状态ID"  class="mini-hidden" required="true" enabled="false" />

        <input id="accountCheckStatusId" name="accountCheckStatusId" value="431" emptyText="分单对账状态ID"  class="mini-hidden"  required="true" enabled="false" />
        <input id="agentDeliveryChargeAccountCheckStatusId" name="agentDeliveryChargeAccountCheckStatusId" value="431" emptyText="代理送货费对账状态ID"  class="mini-hidden"  required="true" enabled="false" />

        <input id="cancelStatusId" name="cancelStatusId" value="411" emptyText="分单作废状态ID"  class="mini-hidden"  required="true" enabled="false" />


        <input id="refundNumber" name="refundNumber" value="0" emptyText="分单拉货时退客户件数"  class="mini-hidden"  required="true" enabled="false" />
        <input id="refundActualWeight" name="refundActualWeight" value="0" emptyText="分单拉货时退客户实际重量"  class="mini-hidden"  required="true" enabled="false" />
        <input id="refundChargeableWeight" name="refundChargeableWeight" value="0" emptyText="分单拉货时退客户计费重量"  class="mini-hidden"  required="true" enabled="false" />
        <input id="refundVolume" name="refundVolume" value="0" emptyText="分单拉货时退客户体积"  class="mini-hidden" required="true" enabled="false" />

        <input id="shareCost" name="shareCost" value="0" emptyText="分摊成本"  class="mini-hidden"  required="true" enabled="false" />
        <input id="shareCostComment" name="shareCostComment"  emptyText="分摊成本说明"  class="mini-hidden"  required="false" enabled="false" />
        <input id="operatingCost" name="operatingCost" value="0" emptyText="操作费"  class="mini-hidden"  required="true" enabled="false" />
        <input id="grossProfit" name="grossProfit" value="0" emptyText="毛利润"  class="mini-hidden"  required="true" enabled="false" />



    </div>

    <!-- 空运时客户协议运价显示 -->
    <div id="airAgreementFreightPanel" class="mini-window" title="空运客户协议运价" style="width:1250px;height:770px;"
         showMaxButton="true" showCollapseButton="false" showMinButton="true" showShadow="true"
         showToolbar="true" showFooter="true" showModal="true" allowResize="true" allowDrag="true">

        <div property="footer" style="padding:10px;text-align: right">
            <a  class="mini-button" iconCls="icon-close" onclick="closeAgreementFreightPanel('airAgreementFreightPanel')">关闭</a>
        </div>


        <div style="width: 100%">
            <span>客户名称:</span>
            <input id="airPanelCustomerName" name="airPanelCustomerName" emptyText="客户名称"  class="mini-textbox" required="false" requiredErrorText="客户名称不能为空" enabled="false" style="width: 200px;" />
            <span>始发机场:</span>
            <input id="airPanelAirportName" name="airPanelAirportName" emptyText="始发机场"  class="mini-textbox"  required="false" requiredErrorText="始发机场不能为空" enabled="false" style="width: 200px;" />
            <span>目的站:</span>
            <input id="airPanelCityName" name="airPanelCityName" emptyText="目的站"  class="mini-textbox"  required="false" requiredErrorText="目的站不能为空" enabled="false"  style="width: 100px;"/>

            <span>航空公司:</span>
            <input id="airPanelAirlinesName" name="airPanelAirlinesName" emptyText="航空公司"  class="mini-textbox"  required="false" requiredErrorText="航空公司不能为空" enabled="false"  style="width: 200px;"/>
            <span>班次号:</span>
            <input id="airPanelFlightNoName" name="airPanelFlightNoName" emptyText="班次号"  class="mini-textbox"  required="false" requiredErrorText="班次号不能为空" enabled="false" style="width: 100px;"/>


            <div style="margin-top: 5px"></div>
            <span>备注:</span>
            <input name="comment" class="mini-textarea" required="false" requiredErrorText="备用字段3不能为空" style="width:400px;height:30px;"/>

            <div style="margin-top: 5px"></div>

            <div style="display: flex;flex-direction: row; width: 100%;height:600px">
                <div style="display: flex;flex-direction: column;width: 50%;height: 100%;margin-right: 2.5px">
                    <div style="display: flex;flex-direction: row;width: 100%;align-items: center">
                        <span>重量运价标准:</span>
                        <span class="separator"></span>
                        <span>货物类型:</span><input id="weightPanelWeightGoodsTypeId" name="goodsTypeId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                                 required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择货物类型" onvaluechanged="weightPanelWeightGoodsTypeIdChange"/>
                    </div>
                    <div style="margin-top: 5px"></div>
                    <div id="airWeightDetailGrid" class="mini-datagrid"
                         style="width: 100%; height: 600px;" idField="id"
                         showPager="false"  allowResize="true">
                        <div property="columns">
                            <div field="goodsTypeId" width="140" headerAlign="center" align="left" data-options='{cacheName:"sysDic"}' renderer="commonRender">货物类型</div>
                            <div field="startValue" width="100" headerAlign="center" align="center">起始值</div>
                            <div field="endValue" width="100" headerAlign="center" align="center">结束值</div>
                            <div field="price" width="120" headerAlign="center" align="center">单价(元/公斤)</div>
                            <div field="comment" width="140" headerAlign="center" align="center">范围说明</div>
                        </div>
                    </div>
                </div>
                <div style="display: flex;flex-direction: column;width: 50%;height: 100%;margin-left: 2.5px">
                    <div style="display: flex;flex-direction: row;width: 100%;align-items: center">
                        <span>体积运价标准:</span>
                        <span class="separator"></span>
                        <span>货物类型:</span><input id="weightPanelVolumeGoodsTypeId" name="goodsTypeId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                                 required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择货物类型" onvaluechanged="weightPanelVolumeGoodsTypeIdChange"/>
                    </div>
                    <div style="margin-top: 5px"></div>
                    <div id="airVolumeDetailGrid" class="mini-datagrid"
                         style="width: 100%; height: 600px;" idField="id"
                         showPager="false"  allowResize="true">
                        <div property="columns">
                            <div field="goodsTypeId" width="140" headerAlign="center" align="left" data-options='{cacheName:"sysDic"}' renderer="commonRender">货物类型</div>
                            <div field="startValue" width="100" headerAlign="center" align="center">起始值</div>
                            <div field="endValue" width="100" headerAlign="center" align="center">结束值</div>
                            <div field="price" width="120" headerAlign="center" align="center">单价(元/方)</div>
                            <div field="comment" width="140" headerAlign="center" align="center">范围说明</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <!-- 汽运时客户协议运价显示 -->
    <div id="autoAgreementFreightPanel" class="mini-window" title="汽运客户协议运价" style="width:1250px;height:770px;"
         showMaxButton="true" showCollapseButton="false" showMinButton="true" showShadow="true"
         showToolbar="true" showFooter="true" showModal="true" allowResize="true" allowDrag="true">

        <div property="footer" style="padding:10px;text-align: right">
            <a  class="mini-button" iconCls="icon-close" onclick="closeAgreementFreightPanel('autoAgreementFreightPanel')">关闭</a>
        </div>


        <div style="width: 100%">
            <span>客户名称:</span>
            <input id="autoPanelCustomerName" name="autoPanelCustomerName" emptyText="客户名称"  class="mini-textbox" required="false" requiredErrorText="客户名称不能为空" enabled="false" style="width: 300px;" />
            <span>目的站:</span>
            <input id="autoPanelCityName" name="autoPanelCityName" emptyText="目的站"  class="mini-textbox"  required="false" requiredErrorText="目的站不能为空" enabled="false"  style="width: 300px;"/>

            <div style="margin-top: 5px"></div>
            <span>备注:</span>
            <input name="comment" class="mini-textarea" required="false" requiredErrorText="备注字段不能为空" style="width:400px;height:30px;"/>


            <div style="margin-top: 5px"></div>

            <div style="display: flex;flex-direction: row; width: 100%;height:600px">
                <div style="display: flex;flex-direction: column;width: 50%;height: 100%;margin-right: 2.5px">
                    <div style="display: flex;flex-direction: row;width: 100%;align-items: center">
                        <span>重量运价标准:</span>
                        <span class="separator"></span>
                        <span>货物类型:</span><input id="autoPanelWeightGoodsTypeId" name="goodsTypeId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                                 required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择货物类型" onvaluechanged="autoPanelWeightGoodsTypeIdChange"/>
                    </div>
                    <div style="margin-top: 5px"></div>
                    <div id="autoWeightDetailGrid" class="mini-datagrid"
                         style="width: 100%; height: 580px;" idField="id"
                         showPager="false"  allowResize="true">
                        <div property="columns">
                            <div field="goodsTypeId" width="140" headerAlign="center" align="left" data-options='{cacheName:"sysDic"}' renderer="commonRender">货物类型</div>
                            <div field="startValue" width="100" headerAlign="center" align="center">起始值</div>
                            <div field="endValue" width="100" headerAlign="center" align="center">结束值</div>
                            <div field="price" width="120" headerAlign="center" align="center">单价(元/公斤)</div>
                            <div field="comment" width="140" headerAlign="center" align="center">范围说明</div>
                        </div>
                    </div>
                </div>
                <div style="display: flex;flex-direction: column;width: 50%;height: 100%;margin-left: 2.5px">
                    <div style="display: flex;flex-direction: row;width: 100%;align-items: center">
                        <span>体积运价标准:</span>
                        <span class="separator"></span>
                        <span>货物类型:</span><input id="autoPanelVolumeGoodsTypeId" name="goodsTypeId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                                 required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择货物类型" onvaluechanged="autoPanelVolumeGoodsTypeIdChange"/>
                    </div>
                    <div style="margin-top: 5px"></div>
                    <div id="autoVolumeDetailGrid" class="mini-datagrid"
                         style="width: 100%; height: 580px;" idField="id"
                         showPager="false"  allowResize="true">
                        <div property="columns">
                            <div field="goodsTypeId" width="140" headerAlign="center" align="left" data-options='{cacheName:"sysDic"}' renderer="commonRender">货物类型</div>
                            <div field="startValue" width="100" headerAlign="center" align="center">起始值</div>
                            <div field="endValue" width="100" headerAlign="center" align="center">结束值</div>
                            <div field="price" width="120" headerAlign="center" align="center">单价(元/方)</div>
                            <div field="comment" width="140" headerAlign="center" align="center">范围说明</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>



    <!-- 根据发货人ID，到分单表中加载相应的收货人列表信息，然后供其选择 -->
    <div id="receiveCustomerPanel" class="mini-window" title="收货人列表" style="width:800px;height:500px;"
         showMaxButton="true" showCollapseButton="false" showMinButton="true" showShadow="true"
         showToolbar="true" showFooter="true" showModal="true" allowResize="true" allowDrag="true">

        <div property="footer" style="padding:10px;text-align: right">
            <a  class="mini-button" iconCls="icon-ok" onclick="selectReceiveCustomer()">选择</a>
            <a  class="mini-button" iconCls="icon-close" onclick="closeReceiveCustomerPanel('receiveCustomerPanel')">关闭</a>
        </div>

        <div id="queryReceiveCustomerForm" class="uc-toolbaroverflow" _borderStyle="border-top:0;">
            <span>收货人:</span>

            <input id="queryDeliveryCustomerId" name="queryDeliveryCustomerId"   class="mini-hidden" required="true" enabled="false" />
            <input id="queryReceiveCustomerName" name="queryReceiveCustomerName" emptyText="收货人名称、电话"  class="mini-textbox" required="false" requiredErrorText="客户名称不能为空"  style="width: 300px;" />

            <a class="mini-button" iconCls="icon-search" onclick="queryReceive()">查询</a>

        </div>
        <div style="margin-top: 5px"></div>
        <div class = "mini-fit">
            <div id="receiveCustomerPanelDatagrid" class="mini-datagrid"
                 style="width: 100%; height: 100%;"
                 url="${base}/pages/native_bill_manage/queryBillReceiveCustomerByDeliveryCustomerId" idField="id"
                 showPager="true" pageSize="10" sizeList="[10,20,30]"
                 multiSelect = "false" allowResize="true"
            >
                <div property="columns">
                    <div type="checkcolumn" >选择</div>
                    <div field="receiveCustomerName" width="140" headerAlign="center" align="center" allowSort="true">收货人名称</div>
                    <div field="receiveCustomerPhone" width="140" headerAlign="center" align="center" allowSort="true">收货人电话</div>
                    <div field="receiveCustomerAddress" width="140" headerAlign="center" align="center" allowSort="true">收货人地址</div>
                </div>
            </div>
        </div>
    </div>


    <!-- 分单打印 -->
    <div id="billPrintPanel" class="mini-window" title="分单打印" style="width:1200px;height:550px;"
         showMaxButton="true" showCollapseButton="false" showMinButton="true" showShadow="true"
         showToolbar="true" showFooter="true" showModal="true" allowResize="true" allowDrag="true">

        <div property="footer" style="padding:10px;text-align: right">
            选择打印机:
            <select id="printList">
                <option></option>
            </select>
            <a  class="mini-button" iconCls="icon-ok" onclick="printPage('1')">打印</a>
            <a  class="mini-button" iconCls="icon-ok" onclick="printPage('2')">打印预览</a>
            <a  class="mini-button" iconCls="icon-ok" onclick="printPage('3')">页面设置</a>
            <a  class="mini-button" iconCls="icon-close" onclick="closePanel('billPrintPanel')">关闭</a>
        </div>

        <!-- 分单内容显示   -->

        <div class="width100" style="display: flex;flex-direction: column;">
            <!-- 分单归属部门 attributionDepartmentId -->
            <div id="billPrintAttributionDepartmentName" style="display: none">分单归属部门</div>
            <!-- 第一行 -->
            <div class="width100 border" style="display: flex; flex-direction: row">
                <div style="width: 25%;border-bottom: none;border-top: none;border-left: none" class="border">
                    <div class="width100" style="display: flex;flex-direction: row">
                        <div style="width: 55%;" >
                            <div style="font-size: 10pt;margin-left: 10px">始发站</div>
                            <div style="font-size: 7pt;margin-left: 10px">Port of Departure</div>
                        </div>
                        <div style="display: flex;align-items: center;justify-content: center;">
                            <!-- cityName -->
                            <div id="billPrintCityName" style="font-size: 13pt">宜兴</div>
                        </div>
                    </div>
                </div>
                <div style="width: 25%;border-bottom: none;border-top: none;border-left: none" class="border">
                    <div class="width100" style="display: flex;flex-direction: row;">
                        <div style="width: 55%;" >
                            <div style="font-size: 10pt;margin-left: 10px">目的站</div>
                            <div style="font-size: 7pt;margin-left: 10px">Port of Destination</div>
                        </div>
                        <div style="display: flex;align-items: center;justify-content: center;">
                            <!-- destCityId -->
                            <div id="billPrintDestCityName" style="font-size: 13pt">深圳</div>
                        </div>
                    </div>
                </div>
                <div style="width: 25%;border-bottom: none;border-top: none;border-left: none" class="border">
                    <div class="width100" style="display: flex;flex-direction: row">
                        <div style="width: 55%;" >
                            <div style="font-size: 10pt;margin-left: 10px">运输方式</div>
                            <div style="font-size: 7pt;margin-left: 10px">Mode of transport</div>
                        </div>
                        <div style="display: flex;align-items: center;justify-content: center;">
                            <!-- transportSpeciesId -->
                            <div id="billPrintTransportSpeciesName" style="font-size: 13pt">航空</div>
                        </div>
                    </div>
                </div>
                <div style="width: 25%">
                    <div class="width100" style="display: flex;flex-direction: row">
                        <div style="width: 55%;" >
                            <div  style="font-size: 10pt;margin-left: 10px">提货方式</div>
                            <div  style="font-size: 7pt;margin-left: 10px">Form of Lading</div>
                        </div>
                        <div style="display: flex;align-items: center;justify-content: center;">
                            <!-- pickUpGoodsWayId -->
                            <div id="billPrintPickUpGoodsWayName" style="font-size: 13pt">自提</div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 第二行 -->
            <div class="width100 border" style="display: flex;flex-direction: row;border-top: none">
                <div class="width50 border" style="display: flex;flex-direction: column;border-top: none;border-left: none;border-bottom: none">
                    <div class="width100">
                        <div  style="font-size: 10pt;margin-left: 10px">发货人姓名、地址、邮编、电话号码</div>
                        <div  style="font-size: 9.3pt;margin-left: 10px">Shipper's Name,Address,Postcode,Telephone number</div>
                    </div>
                    <div class="width100" style="margin-top: 10px">
                        <!-- deliveryCustomerName  deliveryCustomerPhone  deliveryCustomerAddress -->
                        <div id="billPrintDeliveryCustomerName"  style="font-size: 10pt;margin-left: 10px">张小海</div>
                        <div id="billPrintDeliveryCustomerPhone"  style="font-size: 10pt;margin-left: 10px">中国纺织工业</div>
                        <div id="billPrintDeliveryCustomerAddress"  style="font-size: 10pt;margin-left: 10px">010-11223344</div>
                    </div>
                </div>
                <div class="width50" style="display: flex;flex-direction: column">
                    <div class="width100">
                        <div  style="font-size: 10pt;margin-left: 10px">收货人姓名、地址、邮编、电话号码</div>
                        <div  style="font-size: 9.3pt;margin-left: 10px">Consingnee's Name,Address,Postcode,Telephone number</div>
                    </div>
                    <div class="width100" style="margin-top: 10px">
                        <!-- receiveCustomerName  receiveCustomerPhone  receiveCustomerAddress -->
                        <div id="billPrintReceiveCustomerName"  style="font-size: 10pt;margin-left: 10px">张小海</div>
                        <div id="billPrintReceiveCustomerPhone"  style="font-size: 10pt;margin-left: 10px">中国纺织工业</div>
                        <div id="billPrintReceiveCustomerAddress"  style="font-size: 10pt;margin-left: 10px">010-11223344</div>
                    </div>
                </div>
            </div>

            <!-- 第三行 -->
            <div class="width100 border" style="border-top: none; display: flex;flex-direction: row">
                <div style="width:15%;display: flex;flex-direction: column;" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 60px;">
                        <div style="font-size: 12pt;margin-left: 10px">货物品名</div>
                        <div style="font-size: 7.5pt;margin-left: 10px">Description of Goods</div>
                    </div>
                    <div class="width100" style="height:60px; display: flex;align-items: center;justify-content: center"  >
                        <!-- goodsName -->
                        <div id="billPrintGoodsName"  style="font-size: 10pt;">电子配件</div>
                    </div>
                </div>

                <div style="width: 10%;display: flex;flex-direction: column;border-top: none;border-bottom: none" class="border">
                    <div class="width100" style="display: flex;flex-direction: column;height: 60px;">
                        <div  style="font-size: 12pt; margin-left: 10px">件数</div>
                        <div  style="font-size: 7.5pt; margin-left: 10px">No.Of Pcs</div>
                    </div>
                    <div class="width100" style="height:60px;display: flex;align-items: center;justify-content: center">
                        <!-- totalNumber -->
                        <div id="billPrintTotalNumber"  style="font-size: 10pt">总件数</div>
                    </div>
                </div>

                <div style="width: 12%;display: flex;flex-direction: column" >
                    <div class="width100" style="display: flex;flex-direction: column;height: 60px">
                        <div style="font-size: 12pt; margin-left: 10px">实重(kg)</div>
                        <div style="font-size: 7.5pt; margin-left: 10px">Reality Weight(kg)</div>
                    </div>
                    <div class="width100" style="height:60px;display: flex;align-items: center;justify-content: center">
                        <!-- actualWeight -->
                        <div id="billPrintActualWeight"  style="font-size: 10pt">实重</div>
                    </div>
                </div>

                <div style="width: 12%;display: flex;flex-direction: column;border-top: none;border-bottom: none" class="border" >
                    <div class="width100" style="display: flex;flex-direction: column;height: 60px;">
                        <div style="font-size: 12pt; margin-left: 10px">计费重量(kg)</div>
                        <div style="font-size: 7.5pt; margin-left: 10px">Chargcable Weight(kg)</div>
                    </div>
                    <div class="width100" style="height:60px;display: flex;align-items: center;justify-content: center">
                        <!-- chargeableWeight -->
                        <div id="billPrintChargeableWeight"  style="font-size: 10pt">计重</div>
                    </div>
                </div>

                <div style="width: 10%;display: flex;flex-direction: column;" >
                    <div class="width100" style="display: flex;flex-direction: column;height: 60px">
                        <div style="font-size: 12pt; margin-left: 10px">体积</div>
                        <div style="font-size: 7.5pt; margin-left: 10px">Volume</div>
                    </div>
                    <div class="width100" style="height:60px;display: flex;align-items: center;justify-content: center">
                        <!-- volume -->
                        <div id="billPrintVolume"  style="font-size: 10pt">体积</div>
                    </div>
                </div>

                <div style="width: 18%;display: flex;flex-direction: column;border-top: none;border-bottom: none" class="border">
                    <div class="width100" style="display: flex;flex-direction: column;height: 60px;">
                        <div style="font-size: 12pt; margin-left: 10px">班次/日期</div>
                        <div style="font-size: 7.5pt; margin-left: 10px">School grade order/Date</div>
                    </div>
                    <div class="width100" style="height:60px;display: flex;justify-content: center;flex-direction: column">
                        <!-- flightDate  -->
                        <div id="billPrintFlightDate"  style="font-size: 10pt; margin-left: 10px">2011-05-20</div>
                        <!-- flightName    planTakeOffTime 0900  -->
                        <div id="billPrintFlightName"  style="font-size: 10pt; margin-left: 10px">MU2867/0900</div>
                    </div>
                </div>

                <div style="width: 30%;display: flex;flex-direction: column" >
                    <div class="width100" style="display: flex;flex-direction: column;height: 60px">
                        <div style="font-size: 12pt; margin-left: 10px">提货点姓名、地址、电话号码</div>
                        <div style="font-size: 7.5pt; margin-left: 10px">Consingnee's Name,Address,Postcode,Telephone number</div>
                    </div>
                    <div class="width100" style="height:60px;display: flex;justify-content: center;flex-direction: column">
                        <!--   pickUpPointId  pickUpPointName  pickUpPointPhone  pickUpPointAddress -->
                        <div id="billPrintPickUpPointName"  style="font-size: 10pt;margin-left: 10px">宝安物流公司</div>
                        <div id="billPrintPickUpPointAddress"  style="font-size: 10pt;margin-left: 10px">宝安大道108号</div>
                        <div id="billPrintPickUpPointPhone"  style="font-size: 10pt;margin-left: 10px">0755-99008877</div>
                    </div>
                </div>

            </div>

            <!-- 第四行 -->
            <div class="width100 border" style="border-top: none; display: flex;flex-direction: row">
                <div style="width: 12%;display: flex;flex-direction: column" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 30px;align-items: center">
                        <div style="font-size: 10pt">费率</div>
                    </div>
                    <div class="width100" style="height:30px;display: flex;align-items: center;justify-content: center;"  >
                        <!-- weightRate(重量费率) printWeightRate   volumeRate(体积费率) printVolumeRate -->
                        <div id="billPrintWeightRate"  style="font-size: 10pt">0.0</div>
                    </div>
                </div>

                <div class="border" style="width: 12%;display: flex;flex-direction: column; border-top: none; border-bottom: none" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 30px;align-items: center">
                        <div style="font-size: 10pt">运费</div>
                    </div>
                    <div class="width100" style="height:30px;display: flex;align-items: center;justify-content: center;"  >
                        <!-- transportCost(运费合计) -->
                        <div id="billPrintTransportCost"  style="font-size: 10pt">0.0</div>
                    </div>
                </div>

                <div style="width: 12%;display: flex;flex-direction: column" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 30px;align-items: center">
                        <div style="font-size: 10pt">代收货款</div>
                    </div>
                    <div class="width100" style="height:30px;display: flex;align-items: center;justify-content: center;"  >
                        <!-- collectionMoney(代收货款) -->
                        <div id="billPrintCollectionMoney"  style="font-size: 10pt">0.0</div>
                    </div>
                </div>

                <div class="border" style="width: 12%;display: flex;flex-direction: column; border-top: none; border-bottom: none" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 30px;align-items: center">
                        <div style="font-size: 10pt">送货费</div>
                    </div>
                    <div class="width100" style="height:30px;display: flex;align-items: center;justify-content: center;"  >
                        <!-- openBillDeliveryCharge(开单送货费) -->
                        <div id="billPrintOpenBillDeliveryCharge"  style="font-size: 10pt">0.0</div>
                    </div>
                </div>

                <div style="width: 12%;display: flex;flex-direction: column" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 30px;align-items: center">
                        <div style="font-size: 10pt">运输保险</div>
                    </div>
                    <div class="width100" style="height:30px;display: flex;align-items: center;justify-content: center;"  >

                    </div>
                </div>

                <div class="border" style="width: 12%;display: flex;flex-direction: column; border-top: none; border-bottom: none" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 30px;align-items: center">
                        <div style="font-size: 10pt">运输声明</div>
                    </div>
                    <div class="width100" style="height:30px;display: flex;align-items: center;justify-content: center;"  >
                        <!-- declaredValue(声明价值) -->
                        <div id="billPrintDeclaredValue"  style="font-size: 10pt">0.0</div>
                    </div>
                </div>

                <div style="width: 12%;display: flex;flex-direction: column" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 30px;align-items: center">
                        <div style="font-size: 10pt">保险费</div>
                    </div>
                    <div class="width100" style="height:30px;display: flex;align-items: center;justify-content: center;"  >
                        <!-- insuranceRate(保险费率) insuranceFee(保费) -->
                        <div id="billPrintInsuranceFee"  style="font-size: 10pt">0.0</div>
                    </div>
                </div>

                <div class="border" style="width: 12%;display: flex;flex-direction: column; border-top: none; border-bottom: none" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 30px;align-items: center">
                        <div style="font-size: 10pt">附加费</div>
                    </div>
                    <div class="width100" style="height:30px;display: flex;align-items: center;justify-content: center;"  >
                        <!-- fuelSurcharge(燃油费) -->
                        <div id="billPrintFuelSurcharge"  style="font-size: 10pt">0.0</div>
                    </div>
                </div>

                <div style="width: 12%;display: flex;flex-direction: column" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 30px;align-items: center">
                        <div style="font-size: 10pt">其它费用</div>
                    </div>
                    <div class="width100" style="height:30px;display: flex;align-items: center;justify-content: center;"  >
                        <!-- otherCharges(其他费用) -->
                        <div id="billPrintOtherCharges"  style="font-size: 10pt">0.0</div>
                    </div>
                </div>

                <div class="border" style="width: 12%;display: flex;flex-direction: column; border-top: none; border-bottom: none" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 30px;align-items: center">
                        <div style="font-size: 10pt">总额</div>
                    </div>
                    <div class="width100" style="height:30px;display: flex;align-items: center;justify-content: center;"  >
                        <!-- totalAmount(总额) -->
                        <div id="billPrintTotalAmount"  style="font-size: 10pt">0.0</div>
                    </div>
                </div>

                <div style="width: 20%;display: flex;flex-direction: column" >
                    <div class="width100" style="display: flex;flex-direction: column; height: 30px;align-items: center">
                        <div style="font-size: 10pt">付款方式</div>
                    </div>
                    <div class="width100" style="height:30px;display: flex;flex-direction:column;align-items: center;justify-content: center;"  >
                        <!-- deliveryCustomerPaymentMethodId  deliveryCustomerPaymentAmount-->
                        <div style="display: flex;flex-direction: row">
                            <span id="billPrintDeliveryCustomerPaymentMethod" style="font-size: 8pt">到付</span>
                            <span id="billPrintDeliveryCustomerPaymentMethod1" style="font-size: 8pt">(发)</span>
                            <span id="billPrintDeliveryCustomerPaymentAmount" style="font-size: 8pt">200</span>
                        </div>

                        <!-- receiveCustomerPaymentMethodId receiveCustomerPaymentAmount -->
                        <div style="display: flex;flex-direction: row">
                            <span id="billPrintReceiveCustomerPaymentMethod" style="font-size: 8pt">到付</span>
                            <span id="billPrintReceiveCustomerPaymentMethod1" style="font-size: 8pt">(收)</span>
                            <span id="billPrintReceiveCustomerPaymentAmount" style="font-size: 8pt">200</span>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 第五行 -->
            <div class="width100 border" style="border-top: none; display: flex;flex-direction: row">
                <div style="height:60px;width: 25%; display: flex; flex-direction: column;justify-content: center">
                    <div style="font-size: 10pt;margin-left: 10px">储运注意事项及其它</div>
                    <div style="font-size: 7pt;margin-left: 10px">Handling Information and Other</div>
                </div>
                <div class="border" style="height:60px;width: 75%;display: flex;flex-direction:column;justify-content: center;border-top: none;border-bottom:none;border-right: none">
                    <!--comment-->
                    <div id="billPrintComment"  style="font-size: 10pt;margin-left: 10px">备注信息</div>
                </div>
            </div>


            <!-- 第六行 -->
            <div class="width100 border" style="border-top: none; display: flex;flex-direction: row">
                <div style="width: 25%; height: 60px;">
                    <div style="font-size: 10pt;margin-left: 10px">限时服务方式、时效</div>
                    <div style="font-size: 7.5pt;margin-left: 10px">Time-limiting service mode,efficiency</div>
                    <div id="billPrintBillLoadMasterBillIds" style="font-size: 10pt;display: flex;justify-content: center;align-items: center;margin-top: 5px" class="with100">提货单号</div>
                </div>
                <div class="border"  style="width: 50%; height: 60px;border-top: none;border-bottom: none">
                    <div style="width: 70%;display: flex;flex-direction: column;justify-content: center">
                        <div style="font-size: 10pt;margin-left: 10px">托运人或其代理人签字、盖章(同意背面条款)</div>
                        <div style="font-size: 7.5pt;margin-left: 10px">Signature of Shipper or His Agent</div>
                    </div>
                    <div style="width: 30%">

                    </div>
                </div>
                <div style="width: 25%; height: 60px; display: flex; flex-direction: row;">
                    <div style="width: 30%;">
                        <div style="font-size: 8pt;display: flex;justify-content: center;align-items: center" class="width100">填开时间</div>
                        <div style="font-size: 8pt;display: flex;justify-content: center;align-items: center" class="width100">Time</div>
                        <!-- openBillDate -->
                        <div id="billPrintOpenBillDate" style="font-size: 10pt;display: flex;justify-content: center;align-items: center;margin-top: 5px" class="with100">填开时间</div>
                    </div>
                    <div style="width: 40%;">
                        <div style="font-size: 8pt;display: flex;justify-content: center;align-items: center" class="width100">填开地点</div>
                        <div  style="font-size: 8pt;display: flex;justify-content: center;align-items: center" class="width100">Address</div>
                        <!-- cityName -->
                        <div id="billPrintCityName1" style="font-size: 10pt;display: flex;justify-content: center;align-items: center;margin-top: 5px" class="with100">填开地点</div>
                    </div>
                    <div style="width: 30%;">
                        <div style="font-size: 8pt;display: flex;justify-content: center;align-items: center" class="width100">填开人</div>
                        <div style="font-size: 8pt;display: flex;justify-content: center;align-items: center" class="width100">Signature by</div>
                        <!-- openBillUserId -->
                        <div id="billPrintOpenBillUserName"  style="font-size: 10pt;display: flex;justify-content: center;align-items: center;margin-top: 5px" class="with100">填开人</div>
                    </div>
                </div>
            </div>

        </div>

    </div>


    <!-- 标签打印 -->
    <div id="billLabelPrintPanel" class="mini-window" title="分单标签打印" style="width:1250px;height:550px;"
         showMaxButton="true" showCollapseButton="false" showMinButton="true" showShadow="true"
         showToolbar="true" showFooter="true" showModal="true" allowResize="true" allowDrag="true">

        <div property="footer" style="padding:10px;text-align: right">
            选择打印机:
            <select id="labelPrinterList">
                <option></option>
            </select>
            <a  class="mini-button" iconCls="icon-ok" onclick="printLabel('1')">打印</a>
            <a  class="mini-button" iconCls="icon-ok" onclick="printLabel('2')">打印预览</a>
            <a  class="mini-button" iconCls="icon-ok" onclick="printLabel('3')">页面设置</a>
            <a  class="mini-button" iconCls="icon-close" onclick="closePanel('billLabelPrintPanel')">关闭</a>
        </div>

        <div style="margin-bottom: 5px">
            <span style="color: red;font-size: 10pt">标签打印件数范围:</span>
            <span>开始:</span><input id="startIndex" changeOnMousewheel="false" class="mini-spinner"  minValue="1" maxValue="250" style="width: 50px" />
            <span>结束:</span><input id="endIndex" changeOnMousewheel="false" class="mini-spinner"  minValue="1" maxValue="250" style="width: 50px" />
            <a  class="mini-button" iconCls="icon-ok" onclick="generateBillLabel()">生成标签</a>
        </div>

        <div class="mini-fit">
            <div id="labelDatagrid1" class="mini-datagrid" style="width:100%;height:100%;" showHeader="true" title="分单标签"
                 url="${base}/cardJsonData.txt"
                 idField="id" allowResize="true" showPager="false"
                 viewType="cardview" itemRenderer="cardItemRenderer" showColumns="false">
                <div property="columns">

                </div>
            </div>
        </div>

    </div>





    <script type="text/javascript">
        mini.parse();

        let billForm = new mini.Form("#billForm");

        let addBtn = mini.get("addBtn");
        let updateBtn = mini.get("updateBtn");
        let updateSaveBtn = mini.get("updateSaveBtn");

        // 分单归属部门
        let attributionDepartmentId = mini.get("attributionDepartmentId");

        let transportSpeciesId = mini.get("transportSpeciesId");
        let transportWayId = mini.get("transportWayId");
        let transportScopeId = mini.get("transportScopeId");
        // 营业部所在城市ID
        let cityId = mini.get("cityId");
        // 营业部所在城市名称
        let cityName = mini.get("cityName");
        // 目的市
        let destCityId = mini.get("destCityId");

        // 发货人
        let deliveryCustomerId = mini.get("deliveryCustomerId");
        let deliveryCustomerName = mini.get("deliveryCustomerName");
        let deliveryCustomerPhone = mini.get("deliveryCustomerPhone");
        let deliveryCustomerAddress = mini.get("deliveryCustomerAddress");

        // 发货人联系人
        let deliveryCustomerContactId = mini.get("deliveryCustomerContactId");
        let deliveryCustomerContactName = mini.get("deliveryCustomerContactName");
        let deliveryCustomerContactPhone = mini.get("deliveryCustomerContactPhone");

        // 发货人业务员
        let deliveryCustomerSalemanId = mini.get("deliveryCustomerSalemanId");
        let deliveryCustomerSalemanName = mini.get("deliveryCustomerSalemanName");

        // 收货人
        let receiveCustomerName = mini.get("receiveCustomerName");
        let receiveCustomerPhone = mini.get("receiveCustomerPhone");
        let receiveCustomerAddress = mini.get("receiveCustomerAddress");

        // 提货点
        let pickUpPointId = mini.get("pickUpPointId");
        let pickUpPointName = mini.get("pickUpPointName");
        let pickUpPointPhone = mini.get("pickUpPointPhone");
        let pickUpPointAddress = mini.get("pickUpPointAddress");

        // 提货方式
        let pickUpGoodsWayId = mini.get("pickUpGoodsWayId");

        // 签收方式
        let signChooseId = mini.get("signChooseId");

        // 始发机场
        let airportId = mini.get("airportId");

        // 航班日期
        let flightDate = mini.get("flightDate");

        // 班次号
        let flightNo = mini.get("flightNo");
        let flightName = mini.get("flightName");

        // 航空公司
        let airlinesId = mini.get("airlinesId");

        // 计划起飞时间
        let planTakeOffTime = mini.get("planTakeOffTime");

        // 货物名称
        let goodsName = mini.get("goodsName");
        let goodsTypeId = mini.get("goodsTypeId");
        let packingWayId = mini.get("packingWayId");

        // 长 宽 高 件数
        let length = mini.get("length");
        let width = mini.get("width");
        let height = mini.get("height");
        let numberPackages = mini.get("numberPackages");

        // 物品信息
        let volumeInformation = mini.get("volumeInformation");

        // 总件数,由页面填写的信息累计计算得出(可手动直接调整)
        let totalNumber = mini.get("totalNumber");
        // 实际重量,由页面填写的信息累计计算得出(可手动直接调整)
        let actualWeight = mini.get("actualWeight");
        // 计费重量,由页面填写的信息累计计算得出(可手动直接调整)
        let chargeableWeight = mini.get("chargeableWeight");
        // 重量费率,根据选择的客户,自动从客户表中自动带出
        let weightRate = mini.get("weightRate");
        // 体积,体积由页面填写的信息累计计算得出(可手动直接调整)
        let volume = mini.get("volume");
        // 体积费率,根据选择的客户,自动从客户表中自动带出
        let volumeRate = mini.get("volumeRate");
        // 起票价
        let ticketPrice = mini.get("ticketPrice");
        // 运费合计,运费合计=计费重量*重量费率>体积*体积费率?计费重量*重量费率:体积*体积费率
        let transportCost = mini.get("transportCost");

        // 声明价值,默认填写2500
        let declaredValue = mini.get("declaredValue");
        // 保费费率,根据发货客户ID,运输种类,自动带出
        let insuranceRate = mini.get("insuranceRate");
        // 保费,保费=声明价值*保费费率
        let insuranceFee = mini.get("insuranceFee");

        // 开单送货费,公司收取送货给客户的费用
        let openBillDeliveryCharge = mini.get("openBillDeliveryCharge");
        // 代理送货费,公司付给货物目的地代理点的派送费用
        let agentDeliveryCharge = mini.get("agentDeliveryCharge");
        // 送货费用备注
        let deliveryChargeComment = mini.get("deliveryChargeComment");
        // 税金
        let tax = mini.get("tax");
        // 燃油费
        let fuelSurcharge = mini.get("fuelSurcharge");
        // 代收款
        let collectionMoney = mini.get("collectionMoney");
        // 其他费用
        let otherCharges = mini.get("otherCharges");
        // 其他费用说明
        let otherChargesComment = mini.get("otherChargesComment");

        // 其他费用datagrid
        let otherChargeDatagrid = mini.get("otherChargeDatagrid");

        // 业务费
        let serviceCharge = mini.get("serviceCharge");

        // 实收运费,实收运费=运费合计-业务费
        let actualTransportCost = mini.get("actualTransportCost");

        // 业务费分摊类型
        let businessCostAllocationTypeId = mini.get("businessCostAllocationTypeId");
        // 是否分摊业务费用ID
        let businessCostAllocationId = mini.get("businessCostAllocationId");
        // 业务费备注
        let businessCostComment = mini.get("businessCostComment");

        // 打单区域的默认值与上面的实重 计重 区域的默认值是一样的,要求是同步变化
        // 打单实重
        let printActualWeight = mini.get("printActualWeight");
        // 打单计重
        let printChargeableWeight = mini.get("printChargeableWeight");
        // 打单重量费率
        let printWeightRate = mini.get("printWeightRate");
        // 打单体积
        let printVolume = mini.get("printVolume");
        // 打单体积费率
        let printVolumeRate = mini.get("printVolumeRate");

        // 内部操作费
        let innerOperationCharge = mini.get("innerOperationCharge");
        // 发货人付款方式
        let deliveryCustomerPaymentMethodId = mini.get("deliveryCustomerPaymentMethodId");
        // 发货人付款金额
        let deliveryCustomerPaymentAmount = mini.get("deliveryCustomerPaymentAmount");
        // 收货人付款方式
        let receiveCustomerPaymentMethodId = mini.get("receiveCustomerPaymentMethodId");
        // 收货人付款金额
        let receiveCustomerPaymentAmount = mini.get("receiveCustomerPaymentAmount");
        // 总金额
        let totalAmount = mini.get("totalAmount");
        // 实收金额
        let actualAmount = mini.get("actualAmount");

        // 拉货调整金额
        let  dropAmount = mini.get("dropAmount");
        // 结算金额 = 总金额 + 拉货调整金额
        let settlementAmount = mini.get("settlementAmount");

        // 收银员ID
        let cashierId = mini.get("cashierId");
        // 开单人ID
        let openBillUserId = mini.get("openBillUserId");
        // 开单日期
        let openBillDate = mini.get("openBillDate");
        // 开单部门ID
        let openBillDepartmentId = mini.get("openBillDepartmentId");
        // 点到部门ID
        let rollCallDepartmentId = mini.get("rollCallDepartmentId");
        // 备注
        let comment = mini.get("comment");

        // 定义变量
        let transportSpeciesIdData = {air:71,auto:72}

        let pickUpType={air:31,auto:32};

        // 协议运价标准分类
        let standardType={weight:41,volume:42};

        // 同收货人按钮
        let btn1 = mini.get("btn1");
        let btn2 = mini.get("btn2");

        // 获取操作类型
        let opType = "${opType!}";

        // 页面全部加载完成后执行
        $(function (){
            // 运输种类下拉列表
            let transportSpeciesIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_TRANSPORT_SPECIES");
            transportSpeciesId.load(transportSpeciesIdJsonData);

            // 承运方式下拉列表
            let transportWayIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_TRANSPORT_WAY");
            transportWayId.load(transportWayIdJsonData);

            // 运输范围下拉列表
            let transportScopeIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_TRANSPORT_SCOPE");
            transportScopeId.load(transportScopeIdJsonData);

            // 加载目的城市下拉列表
            let destCityIdJsonData=commonRenderDropList("city");
            destCityId.loadList(destCityIdJsonData,"id","pid");

            // 发货人下拉列表
            let deliveryCustomerIdJsonData = commonRenderDropList("customer");
            deliveryCustomerId.load(deliveryCustomerIdJsonData);

            // 提货点下拉列表
            let pickUpPointIdJsonData = commonRenderDropList("pickUpPoint");
            pickUpPointId.load(pickUpPointIdJsonData);

            // 提货方式下拉列表
            let pickUpGoodsWayIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_PICK_UP_GOODS_WAY");
            pickUpGoodsWayId.load(pickUpGoodsWayIdJsonData);

            // 签收方式下拉列表
            let signChooseIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_SIGN_CHOOSE");
            signChooseId.load(signChooseIdJsonData);

            // 加载机场
            let airportIdJsonData = commonRenderDropList("airport");
            airportId.load(airportIdJsonData);

            // 货物类型下拉列表
            let goodsTypeIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_GOODS_TYPE");
            goodsTypeId.load(goodsTypeIdJsonData);

            // 包装方式下拉列表
            let packingWayIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_PACKING_WAY");
            packingWayId.load(packingWayIdJsonData);

            // 业务费分摊类型下拉列表
            let businessCostAllocationTypeIdJsonData = commonRenderSysDicDropListByKey("sysDic","XT_DIC_BUSINESS_COST_ALLOCATION_TYPE");
            businessCostAllocationTypeId.load(businessCostAllocationTypeIdJsonData);

            // 发货人付款方式
            let deliveryCustomerPaymentMethodIdJsonData = commonRenderSysDicDropListByKey("sysDic","XT_DIC_DELIVERY_CUSTOMER_PAYMENT_METHOD");
            deliveryCustomerPaymentMethodId.load(deliveryCustomerPaymentMethodIdJsonData);

            // 收货人付款方式
            let receiveCustomerPaymentMethodIdJsonData = commonRenderSysDicDropListByKey("sysDic","XT_DIC_RECEIVE_CUSTOMER_PAYMENT_METHOD");
            receiveCustomerPaymentMethodId.load(receiveCustomerPaymentMethodIdJsonData);

            // 加载收银员与开单员数据
            let userJsonData = getCacheList("sysUser");
            cashierId.load(userJsonData);
            // 开单员列表加载
            openBillUserId.load(public_deepClone(userJsonData));

            // 加载开单部门
            let departmentJsonData = getCacheList("department");
            openBillDepartmentId.loadList(departmentJsonData,"id","pid");

            // 加载点到部门(注意：点到部门默认放开)
            rollCallDepartmentId.loadList(public_deepClone(departmentJsonData),"id","pid");
            // 分单归属部门
            attributionDepartmentId.loadList(public_deepClone(departmentJsonData),"id","pid");

            // let addBtn = mini.get("addBtn");
            // let saveBtn = mini.get("saveBtn");
            // let updateSaveBtn = mini.get("updateSaveBtn");

            if(opType=="add"){
                // 班次号名称隐藏
                flightName.hide();

                if(addBtn!=undefined){
                    addBtn.show();
                }


                if(updateBtn!=undefined){
                    updateBtn.hide();
                }

                if(updateSaveBtn!=undefined){
                    updateSaveBtn.hide();
                }


                // 设置默认选择
                setDefaultValue();
            }
            else{
               if(opType == "view"){
                   if(addBtn!=undefined){
                       addBtn.hide();
                   }

                   if(updateBtn!=undefined){
                       updateBtn.hide();
                   }

                   if(updateSaveBtn!=undefined){
                       updateSaveBtn.hide();
                   }

               }
               else if(opType="update"){
                   if(addBtn!=undefined){
                       addBtn.hide();
                   }

                   if(updateBtn!=undefined){
                       updateBtn.show();
                   }

                   if(updateSaveBtn!=undefined){
                       updateSaveBtn.show();
                   }
               }

                // 这是编辑
                mini.get("id").set({enabled:false});
                // 1.判断一个是不是空运，根据flightNo是否有值进行判断
                let flightNoValue = public_toNumber('${bNativeBillPojo.transportSpeciesId!}',-1);
                transportSpeciesIdChangeByValue(flightNoValue);

                if(flightNoValue == transportSpeciesIdData.air){
                    pickUpPointId.show();
                    pickUpPointId.set({required:true});
                    pickUpPointName.hide();
                    pickUpPointName.set({required:false});
                }
                else{
                    pickUpPointId.hide();
                    pickUpPointId.set({required:false});
                    pickUpPointName.show();
                    pickUpPointName.set({required:true});
                }

                // 设置数据基本过程
                // 1.先加载相应的下拉列表，2.设置表单值 3.补设置没有定义在分单对象中的值

                if(public_isEmpty("${bNativeBillPojo.pickUpPointId!}")){
                    // 同收货人
                    btn1.hide();
                    btn2.show();
                }
                else{
                    btn1.show();
                    btn2.hide();
                }

                // 绑定联系人列表
                deliveryCustomerContactId.load(${contactPojos!});
                // 绑定班次号列表
                flightNo.load(${bFlightList!});

                // 设定表单数据
                billForm.setData(${bNativeBillPojo!});

                // 设置业务员名称
                deliveryCustomerSalemanName.setValue("${salemanName!}");
                // 获取业务员所在城市名称
                let cityNameValue = commonRendderNameByKeyAndId("city","${bNativeBillPojo.cityId!}");
                cityName.setValue(cityNameValue);
                // 获取分单对象对应的其他费用列表
                let otherChargeListStr = '${bNativeBillPojo.otherChargeList!}';
                // 转为json对象
                let otherChargeList = $.parseJSON(otherChargeListStr);
                // 绑定其他费用数据
                if(otherChargeList.length>0){
                    for (let i=0 ; i<otherChargeList.length; i++)
                    {
                        let newRow = otherChargeList[i];
                        otherChargeDatagrid.addRow(newRow);
                    }
                }

                // 提货点处理一下
                if(public_isEmpty(${bNativeBillPojo.pickUpPointId!})){
                    //pickUpPointId.clear();
                    pickUpPointId.hide();
                    pickUpPointId.set({required:false})
                    pickUpPointName.show();
                    pickUpPointName.set({required:true});
                    btn1.hide();
                    btn2.show();
                }
                else{
                    // 要根据目的站与运输类型架下拉列表
                    // destCityId  transportSpeciesId
                    let filteDestCityId = destCityId.getValue();
                    let filtePickUpTypeId= pickUpType.air;
                    if(transportSpeciesId.getValue() ==transportSpeciesIdData.auto){
                        filtePickUpTypeId=pickUpType.auto;
                    }
                    filtePickupPoint(filteDestCityId,filtePickUpTypeId);
                    pickUpPointId.show();
                    pickUpPointName.hide();
                    btn1.show();
                    btn2.hide();
                }
            }

        });

        /**
         * 分单号校验
         */
        function idChange(){
            if(isEmpty(mini.get("id"),"分单号")){
                return ;
            }
            // 去除分单号两边空格
            let idValue = public_trim(mini.get("id").getValue());
            // 发一个ajax请求
            let ret = public_getServerData("${base}/pages/bill_code_manage/b_native/checkBillCodeId",{billCodeId:idValue});
            if(!ret.ok){
                mini.get("id").setValue("");
                showAlert("分单号: " + idValue + " " + ret.message);
            }
        }


        function transportSpeciesIdChangeByValue(value){
            // 班次日期要清空
            flightDate.setValue();
            if(value == transportSpeciesIdData.air){
                // 显示始发机场标题
                $("#startAirportSpan").show();
                // 显示机场选择
                airportId.set({visible:true,required:true});
                // 设置机航空公司为必填,注意这是代码实现的，因为这它是不显示的
                airlinesId.set({required:true});

                // 设置航班为只能选择
                flightNo.set({allowInput:false,showClose:true,required:true});
                // 显示航班选择
                flightNo.show();

                // 时间设置不可以填写,根据选择的航班号直接设定
                planTakeOffTime.setValue();
                planTakeOffTime.set({enabled:false,required:true});


                // 设置班次名称为非必填
                flightName.set({required:false});
                // 清空值
                flightName.setValue();
                // 隐藏班次名称
                flightName.hide();
            }
            else{
                // 这是汽运
                // 隐藏始发机场标题
                $("#startAirportSpan").hide();
                airportId.set({visible:false,required:false});
                // 设置航空公司为非必填
                airlinesId.set({required:false});
                // 清空已选择的始发机场
                airportId.setValue();
                // 清空已经选择的航空公司
                airlinesId.setValue();

                // 设置航班号为非必填
                flightNo.setRequired(false);
                // 隐藏空运航号下拉列表对象
                flightNo.hide();
                // 清空航班
                flightNo.setValue();

                flightNo.load({});

                // 时间设置可以填写
                planTakeOffTime.setValue();
                planTakeOffTime.set({enabled:true,required:true});


                // 设置班次号名称为必填
                flightName.setRequired(true);
                // 清空其值
                flightName.setValue();
                // 显示班次号名称
                flightName.show();

            }
        }

        /**
         * 运输种类变化,控制始发机场是否显示及必填
         */
        function transportSpeciesIdChange(){
            // 1.隐藏始发机场，并将其设置为非必填  airportId
            let transportSpeciesIdValue = public_toNumber(transportSpeciesId.getValue(),-1);
            transportSpeciesIdChangeByValue(transportSpeciesIdValue);
        }

        // 提货点检索Url
        let pickUpPointIdUrl = "${base}/pages/basic_data_manage/xt_pick_up_point/queryPickUpPointByCondition?cityId=";

        // 根据目的市与提货点类型从缓存的提货点列表中过滤符合条件的提货点列表
        function filtePickupPoint(filteCestCityId,filtePickUpTypeId){
            let pickUpPointIdJsonData = commonRenderDropList("pickUpPoint");
            let pickUpPointArray=[];
            for(let obj of pickUpPointIdJsonData){
                if(obj.cityId==filteCestCityId && obj.pickUpTypeId==filtePickUpTypeId){
                    pickUpPointArray.push(obj);
                }
            }
            pickUpPointId.load(pickUpPointArray);
        }

        /**
         * 目标城市修改时修改目标url
         */
        function destCityIdChange(e){
            // 当前选择的目的市
            let filterDestCityId = e.value;
            // 当前的运输种类
            let filterTransportSpeciesId = transportSpeciesId.getValue();

            if(!public_isEmpty(filterDestCityId) && !public_isEmpty(filterTransportSpeciesId)){
                let filterPickUpTypeId = pickUpType.air;
                if(filterTransportSpeciesId == transportSpeciesIdData.auto){
                    filterPickUpTypeId = pickUpType.auto;
                }
                filtePickupPoint(filterDestCityId,filterPickUpTypeId);
            }

            // 航班处理
            // 运输种类没有选择，就直接返回
            if(public_isEmpty(filterTransportSpeciesId)){
                return;
            }

            let transportSpeciesIdValue = public_toNumber(filterTransportSpeciesId,-1);
            if(transportSpeciesIdValue == transportSpeciesIdData.auto){
                // 这是汽运，直接返回
                flightNo.set({allowInput:true,showClose:false,required:false});
                // 时间设置可以填写
                planTakeOffTime.set({enabled:true,required:true});
                airlinesId.set({required:false});
                return ;
            }
            else{
                flightNo.set({allowInput:false,showClose:true,required:true});
                planTakeOffTime.set({enabled:false,required:true});
                airlinesId.set({required:true});
            }

            let airportIdValue = airportId.getValue();
            let flightDateValue = flightDate.getFormValue();
            if(public_isEmpty(airportIdValue) || public_isEmpty(flightDateValue)){
                planTakeOffTime.setValue();
                return;
            }

            // 加载后直接返回List
            let ret = public_getServerData("${base}/pages/flight_manage/queryFlightNoListByDropCnd",
                {
                    cityId : filterDestCityId,
                    airportId : airportIdValue,
                    flightDate : flightDateValue
                });
            // 绑定数据
            flightNo.load(ret);
        }

        /**
         * 设置发货人名称、电话、地址
         * 同时根据发货人id，查询其对应的联系人列表
         */
        function setDeliveryCustomer(e){
            let selectItem = e.selected;
            if(!public_isEmpty(selectItem)){
                deliveryCustomerName.setValue(selectItem.name);
                deliveryCustomerPhone.setValue(selectItem.phone);
                deliveryCustomerAddress.setValue(selectItem.address);

                // 选择客户的归属部门
                if(!public_isEmpty(selectItem.departmentId)){
                    attributionDepartmentId.setValue(selectItem.departmentId);
                    attributionDepartmentId.set({enabled:false});
                }
                else{
                    attributionDepartmentId.set({enabled:true});
                }

                // 设置客户的业务员
                deliveryCustomerSalemanId.setValue(selectItem.salesmanId);

                // 根据业务员id，检索出对应的id的人员姓名
                let salemanName = commonRendderNameByKeyAndId("sysUser",selectItem.salesmanId);
                deliveryCustomerSalemanName.setValue(salemanName);

                // 根据选择的运输种类，确定保险费率
                // 取出运输种类id
                let transportSpeciesIdValue = transportSpeciesId.getValue();
                if(public_isEmpty(transportSpeciesIdValue) ||  transportSpeciesIdValue == transportSpeciesIdData.air){
                    insuranceRate.setValue(public_toNumber(selectItem.airFreightInsuranceRate,0));
                }
                else{
                    insuranceRate.setValue(public_toNumber(selectItem.autoInsuranceRate,0));
                }

                // 根据联系人id加载发货人的联系人，如果只有一个，则直接设置为这个联系人，如果有多个，则绑定数据，让开单人自己选择
                // 发一个ajax请求
                let ret = public_getServerData("${base}/pages/customer_manage/contact/queryContactByCustomerId",{customerId:selectItem.id});

                if(ret.length>0){
                    deliveryCustomerContactId.load(ret);
                    if(ret.length == 2){
                        // 只有两项，一项是为null 一项是查询的只有一个联系人，则就必须选择了
                        deliveryCustomerContactId.select(1);
                        deliveryCustomerContactName.setValue(ret[1].name);
                        deliveryCustomerContactPhone.setValue(ret[1].phone);
                    }
                }

                // 同步计算出保险费
                calcInsuranceFee();
            }
        }

        /**
         * 根据选择的联系人更换联系人信息
         * @param e
         */
        function setContract(){
            let selectItem=deliveryCustomerContactId.getSelected();
            if(!public_isEmpty(selectItem)){
                deliveryCustomerContactName.setValue(selectItem.name);
                deliveryCustomerContactPhone.setValue(selectItem.phone);
            }
            else{
                deliveryCustomerContactName.setValue('');
                deliveryCustomerContactPhone.setValue('');
            }
        }

        let btnOption = {btn1:1,btn2:2};
        /**
         * 提货点同收货人
         */
        function equalReceiveCustomer(btnValue){
            /**
             * 1.pickUpPointId设置为非必填
             * 2.pickUpPointId隐藏
             * 3.pickUpPointName显示
             * 4.pickUpPointName设置为必填
             */
            // btn1 同收货人  btn2 提货点选择
            if(btnValue == btnOption.btn1){
                btn1.hide();
                btn2.show();
                synchronousChange(pickUpPointName,receiveCustomerName);
                synchronousChange(pickUpPointPhone,receiveCustomerPhone);
                synchronousChange(pickUpPointAddress,receiveCustomerAddress);
                pickUpPointId.hide();
                pickUpPointId.setRequired(false);
                pickUpPointId.setValue();
                pickUpPointName.setRequired(true);
                pickUpPointName.show();
            }
            else{
                btn1.show();
                btn2.hide();

                setObjValue(pickUpPointName,"");
                setObjValue(pickUpPointPhone,"");
                setObjValue(pickUpPointAddress,"");

                pickUpPointId.show();
                pickUpPointId.setRequired(true);
                pickUpPointName.setRequired(false);
                pickUpPointName.hide();
            }
        }


        /**
         * 提货点信息设置
         */
        function setUpPointInfo(){
            let selectItem=pickUpPointId.getSelected();
            if(!public_isEmpty(selectItem)){
                pickUpPointName.setValue(selectItem.name);
                pickUpPointPhone.setValue(selectItem.phone);
                pickUpPointAddress.setValue(selectItem.address);
            }
            else{
                pickUpPointName.setValue('');
                pickUpPointPhone.setValue('');
                pickUpPointAddress.setValue('');
            }
        }

        /**
         * 始发机场改变
         *
         */
        function airportIdValueChanged(){
            // 运输种类
            if(isEmpty(transportSpeciesId,"运输种类")){
                flightDate.setValue();
                return ;
            }
            else{
                let transportSpeciesIdValue = public_toNumber(transportSpeciesId.getValue(),-1);
                if(transportSpeciesIdValue == transportSpeciesIdData.auto){
                    // 这是汽运，直接返回
                    flightNo.set({allowInput:true,showClose:false,required:false});
                    // 时间设置可以填写
                    planTakeOffTime.set({enabled:true,required:true});
                    airlinesId.set({required:false});
                    return ;
                }
                else{
                    flightNo.set({allowInput:false,showClose:true,required:true});
                    planTakeOffTime.set({enabled:false,required:true});
                    airlinesId.set({required:true});
                }
            }

            // 目的市
            let destCityIdValue = destCityId.getValue();
            if(isEmpty(destCityId,"目的市")){
                flightDate.setValue();
                planTakeOffTime.setValue();
                return ;
            }

            let airportIdValue = airportId.getValue();
            // 机场
            if(public_isEmpty(airportIdValue)){
                flightDate.setValue();
                planTakeOffTime.setValue();
                return ;
            }

            // 当前选择的日期值
            let flightDateValue = flightDate.getFormValue();
            if(public_isEmpty(flightDateValue)){
                return ;
            }

            // 加载后直接返回List
            let ret = public_getServerData("${base}/pages/flight_manage/queryFlightNoListByDropCnd",
                {
                    cityId : destCityIdValue,
                    airportId : airportIdValue,
                    flightDate : flightDateValue
                });
            // 绑定数据
            flightNo.load(ret);

        }

        /**
         * 航班日期选择框日期值改变  airlinesId
         *
         */
        function onFlightDateValueChanged(){
            // 如果是汽运则不做加载

            // 2.设置航班日期的值改变事件不去加载航班信息，让客户自己填写
            // 3.班次号应该改为手工填写，
            // 4.放开时间,可以手动填写

            // 运输种类
            if(isEmpty(transportSpeciesId,"运输种类")){
                flightDate.setValue();
                return ;
            }
            else{
                let transportSpeciesIdValue = public_toNumber(transportSpeciesId.getValue(),-1);
                if(transportSpeciesIdValue == transportSpeciesIdData.auto){
                    // 这是汽运，直接返回
                    flightNo.set({allowInput:true,showClose:false,required:false});
                    // 时间设置可以填写
                    planTakeOffTime.set({enabled:true,required:true});
                    airlinesId.set({required:false});
                    return ;
                }
                else{
                    flightNo.set({allowInput:false,showClose:true,required:true});
                    planTakeOffTime.set({enabled:false,required:true});
                    airlinesId.set({required:true});
                }
            }

            // 承运方式值
            if(isEmpty(transportWayId,"承运方式")){
                flightDate.setValue();
                planTakeOffTime.setValue();
                return ;
            }

            // 目的市
            if(isEmpty(destCityId,"目的市")){
                flightDate.setValue();
                planTakeOffTime.setValue();
                return ;
            }
            let destCityIdValue = destCityId.getValue();
            // 机场
            if(isEmpty(airportId,"始发机场")){
                flightDate.setValue();
                planTakeOffTime.setValue();
                return ;
            }
            let airportIdValue = airportId.getValue();

            // 当前选择的日期值
            let flightDateValue = flightDate.getFormValue();

            // 加载后直接返回List
            let ret = public_getServerData("${base}/pages/flight_manage/queryFlightNoListByDropCnd",
                {
                    cityId : destCityIdValue,
                    airportId : airportIdValue,
                    flightDate : flightDateValue
                });
            // 绑定数据
            flightNo.load(ret);

        }

        /**
         * 航班选择按钮关闭按钮被点击
         */
        function flightOnCloseClick(e) {
            let obj = e.sender;
            obj.setText("");
            obj.setValue("");
            // 请空起飞时间
            planTakeOffTime.setValue("");
            // 清空航空公司
            airlinesId.setValue("");
        }

        /**
         * 起飞班次值改变
         */
        function flightOnValueChange(){
            // 判断一下是空运还是汽运，如果是空运可以响应事件，如果汽运则直接返回，不用响应事件处理
            let transportSpeciesIdValue = public_toNumber(transportSpeciesId.getValue(),-1);
            if(transportSpeciesIdValue == transportSpeciesIdData.auto){
                return ;
            }
            let selectedItem=flightNo.getSelected();
            planTakeOffTime.setValue(selectedItem.planTakeOffTime);
            airlinesId.setValue(selectedItem.airlinesId);
            flightName.setValue(selectedItem.name);
        }

        /**
         * 体积计算,根据长宽高进行计算
         */
        function calcVolume(){
            // 1.获取 长 宽 高 件数 三个文本框的值,同时判断是不是有效的数值
            // 同步构建休息信息
            let volumeInfo = "{货物名称:" + goodsName.getValue() +  ",";
            if(isNonNumeric(length,"长度")){
                return ;
            }
            let lengthValue = public_toNumber(length.getValue(),-1);
            volumeInfo += "长:" + lengthValue + ",";

            if(isNonNumeric(width,"宽度")){
                return ;
            }
            let widthValue = public_toNumber(width.getValue(),-1);
            volumeInfo += "宽:" + widthValue + ",";

            if(isNonNumeric(height,"高度")){
                return ;
            }
            let heightValue = public_toNumber(height.getValue(), -1);
            volumeInfo += "高:" + heightValue + ",";

            if(isNonNumeric(numberPackages,"件数")){
                return ;
            }
            let numberPackagesValue = public_toNumber(numberPackages.getValue(),0);
            volumeInfo += "件数:" + numberPackagesValue + "}";

            // 2.判断三个值是不是数值
            if(isEmpty(transportSpeciesId,"运输种类")){
                return ;
            }
            // 取出运输种类id
            let transportSpeciesIdValue = transportSpeciesId.getValue();

            // 取出休息信息
            let volumeInformationValue = volumeInformation.getValue();

            // 取出页上 总件数、总实重、总计重、总体积的当前值
            let totalNumberValue = public_toNumber(totalNumber.getValue(),0);
            let actualWeightValue = public_toNumber(actualWeight.getValue(),0);
            let chargeableWeightValue = public_toNumber(chargeableWeight.getValue(),0);
            let volumeValue = public_toNumber(volume.getValue(),0);

            // 设置总件数 原件数 + 新输入的件数
            totalNumber.setValue(totalNumberValue + numberPackagesValue);

            // 得到新输入信息的体积,保留两位小数
            let newCalcVolume = public_round2(lengthValue * widthValue * heightValue * numberPackagesValue);

            // 设置体积显示的信息
            volumeInformationValue += volumeInfo + " ";
            volumeInformation.setValue(volumeInformationValue);

            // 计算出的实重与计费重量
            let newChargeableWeight = 0;
            let newactualWeightValue = 0;
            let newVolume = 0;

            // 定义运输种类
            if(transportSpeciesIdValue==transportSpeciesIdData.air){
                // 得出计费重量 新计费重量=原计费重量 + 新输入的休积/6000
                newChargeableWeight = public_round2(chargeableWeightValue + newCalcVolume/6000);
                // 实重
                newactualWeightValue = public_round2(actualWeightValue + newCalcVolume/6000);
                // 新体积累计 = 原体积累计 + 新体积 / 1000000
                newVolume = public_round2(volumeValue + newCalcVolume/1000000);
            }
            else{

                // 新的计费重量 = 原计费重量 + 新计费重量 * 250;
                newChargeableWeight = public_round2(chargeableWeightValue + newCalcVolume / 1000000 * 250);
                newactualWeightValue = public_round2(actualWeightValue + newCalcVolume / 1000000 * 250);
                // 新体积累计 = 原体积累计 + 新体积 / 1000000
                newVolume = public_round2(volumeValue + newCalcVolume/1000000);
            }
            // 设置新的计费重量
            chargeableWeight.setValue(newChargeableWeight);
            // 设置实重与计重同步
            actualWeight.setValue(newactualWeightValue);
            // 设置体积
            volume.setValue(newVolume);

            // 同步分摊开单数据
            synchronousChange(printActualWeight,actualWeight);
            synchronousChange(printChargeableWeight,chargeableWeight);
            synchronousChange(printWeightRate,weightRate);
            synchronousChange(printVolume,volume);
            synchronousChange(printVolumeRate,volumeRate);
            // 清空长宽高及件数
            setObjValue(length,"");
            setObjValue(width,"");
            setObjValue(height,"");
            setObjValue(numberPackages,"");


            // 根据条件加载客户的费率


        }

        /**
         * 这是显示空运费率
         */
        function showAirPanel(){

            /**
             * customer_id 发货人
             airport_id 始发机场
             city_id  目的市
             airlines_id 航空公司
             flight_no 班次号
             */

            if(isEmpty(destCityId,"目的市")){
                return ;
            }

            if(isEmpty(deliveryCustomerId,"发货人")){
                return ;
            }

            if(isEmpty(airportId,"始发机场")){
                return ;
            }

            if(isEmpty(airlinesId,"航空公司")){
                return ;
            }

            if(isEmpty(flightNo,"班次号")){
                return;
            }

            if(isNonNumeric(chargeableWeight,"计费重量")){
                return ;
            }
            if(isNonNumeric(volume,"体积")){
                return ;
            }

            // 目的市 ID
            let destCityIdValue = destCityId.getValue();
            let destCityNameValue = commonRendderNameByKeyAndId("city",destCityIdValue);
            // 客户 ID
            let deliveryCustomerIdValue = deliveryCustomerId.getValue();
            let deliveryCustomerName = commonRendderNameByKeyAndId("customer",deliveryCustomerIdValue);
            // 始发机场 ID
            let airportIdValue = airportId.getValue();
            let airportName = commonRendderNameByKeyAndId("airport",airportIdValue);
            // 航空公司 ID
            let airlinesIdValue = airlinesId.getValue();
            let airlinesName = commonRendderNameByKeyAndId("airlines",airlinesIdValue);
            // 获取计费重量及体积
            // let chargeableWeightValue = public_toNumber(chargeableWeight.getValue(),0);
            // let volumeValue = public_toNumber(volume.getValue(),0);

            let flightNameValue = flightName.getValue();

            mini.get("airPanelCustomerName").setValue(deliveryCustomerName);
            mini.get("airPanelAirportName").setValue(airportName);
            mini.get("airPanelCityName").setValue(destCityNameValue);
            mini.get("airPanelAirlinesName").setValue(airlinesName);
            mini.get("airPanelFlightNoName").setValue(flightNameValue);

            let weightPanelWeightGoodsTypeIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_GOODS_TYPE");
            mini.get("weightPanelWeightGoodsTypeId").load(weightPanelWeightGoodsTypeIdJsonData);
            mini.get("weightPanelVolumeGoodsTypeId").load(public_deepClone(weightPanelWeightGoodsTypeIdJsonData));

            let requestParam = {customerId:deliveryCustomerIdValue, airportId:airportIdValue, cityId:destCityIdValue, airlinesId:airlinesIdValue, flightNo:flightNameValue};
            let ret = public_getServerData("${base}/pages/customer_manage/freight_agreement/air/showAirAgreementDetail",requestParam);

            if(public_isEmpty(ret) || ret.length==0){
               showAlert("根据【客户】【始发机场】【目的市】【航空公司】【航班号】没有加载到对应的协议运价信息");
               return;
            }

            customerAirAgreementDetailList.splice(0,customerAirAgreementDetailList.length);
            customerAirAgreementDetailList = ret || [];

            let airWeightDetailGrid = mini.get("airWeightDetailGrid");
            let airVolumeDetailGrid = mini.get("airVolumeDetailGrid");

            // 先清空再显示
            airWeightDetailGrid.clearRows();
            airVolumeDetailGrid.clearRows();

            if(customerAirAgreementDetailList.length>0){
                // 做数据分离显示
                for(let obj of customerAirAgreementDetailList){
                    if(obj.standardTypeId == standardType.weight){
                        airWeightDetailGrid.addRow(obj);
                    }
                    else{
                        airVolumeDetailGrid.addRow(obj);
                    }
                }
            }

            // 显示空运费率面板
            public_showModelAtPos("airAgreementFreightPanel", "center", "middle");

        }


        // weightPanelWeightGoodsTypeId (weightPanelWeightGoodsTypeIdChange) weightPanelVolumeGoodsTypeId (weightPanelVolumeGoodsTypeIdChange)
        function weightPanelWeightGoodsTypeIdChange(e){
            let selectValue = e.value;
            // 先清空 grid
            let airWeightDetailGrid = mini.get("airWeightDetailGrid");
            airWeightDetailGrid.clearRows();
            if(!public_isEmpty(selectValue)){
                for(let obj of customerAirAgreementDetailList){
                    if(obj.standardTypeId == standardType.weight && obj.goodsTypeId == selectValue){
                        airWeightDetailGrid.addRow(obj);
                    }
                }
            }
            else {
                for(let obj of customerAirAgreementDetailList){
                    if(obj.standardTypeId == standardType.weight){
                        airWeightDetailGrid.addRow(obj);
                    }
                }
            }
        }

        function weightPanelVolumeGoodsTypeIdChange(e){
            let selectValue = e.value;
            // 先清空 grid
            let airVolumeDetailGrid = mini.get("airVolumeDetailGrid");
            airVolumeDetailGrid.clearRows();
            if(!public_isEmpty(selectValue)){
                for(let obj of customerAirAgreementDetailList){
                    if(obj.standardTypeId == standardType.volume && obj.goodsTypeId == selectValue){
                        airVolumeDetailGrid.addRow(obj);
                    }
                }
            }
            else {
                for(let obj of customerAirAgreementDetailList){
                    if(obj.standardTypeId == standardType.volume){
                        airVolumeDetailGrid.addRow(obj);
                    }
                }
            }
        }

        let customerAirAgreementDetailList = [];
        let customerAutoAgreementDetailList = [];

        /**
         * 这是显示汽运费率
         */
        function showAutoPanel(){

            if(isEmpty(destCityId,"目的市")){
                return ;
            }

            if(isEmpty(deliveryCustomerId,"发货人")){
                return ;
            }

            // 目的市 ID
            let destCityIdValue = destCityId.getValue();
            let destCityNameValue = commonRendderNameByKeyAndId("city",destCityIdValue);
            // 客户 ID
            let deliveryCustomerIdValue = deliveryCustomerId.getValue();
            let deliveryCustomerName = commonRendderNameByKeyAndId("customer",deliveryCustomerIdValue);

            mini.get("autoPanelCustomerName").setValue(deliveryCustomerName);
            mini.get("autoPanelCityName").setValue(destCityNameValue);

            let autoPanelWeightGoodsTypeIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_GOODS_TYPE");
            mini.get("autoPanelWeightGoodsTypeId").load(autoPanelWeightGoodsTypeIdJsonData);
            mini.get("autoPanelVolumeGoodsTypeId").load(public_deepClone(autoPanelWeightGoodsTypeIdJsonData));


            let baseUrl = "${base}/pages/customer_manage/freight_agreement/auto/showAutoAgreementDetail";
            let param = {customerId:deliveryCustomerIdValue, cityId:destCityIdValue};
            let ret = public_getServerData(baseUrl,param) || [];

            customerAutoAgreementDetailList.splice(0,customerAutoAgreementDetailList.length);
            customerAutoAgreementDetailList = ret;

            let autoWeightDetailGrid = mini.get("autoWeightDetailGrid");
            let autoVolumeDetailGrid = mini.get("autoVolumeDetailGrid");
            autoWeightDetailGrid.clearRows();
            autoVolumeDetailGrid.clearRows();

            if(customerAutoAgreementDetailList.length > 0){
                // 做数据分离显示
                for(let obj of customerAutoAgreementDetailList){
                    if(obj.standardTypeId == standardType.weight){
                        autoWeightDetailGrid.addRow(obj);
                    }
                    else{
                        autoVolumeDetailGrid.addRow(obj);
                    }
                }
            }

            // 显示汽运费率面板
            public_showModelAtPos("autoAgreementFreightPanel", "center", "middle");

        }



        // // autoPanelWeightGoodsTypeId autoPanelWeightGoodsTypeIdChange autoPanelVolumeGoodsTypeId  autoPanelVolumeGoodsTypeIdChange
        // autoWeightDetailGrid  autoVolumeDetailGrid

        function autoPanelWeightGoodsTypeIdChange(e){
            let selectValue = e.value;
            // 先清空 grid
            let autoWeightDetailGrid = mini.get("autoWeightDetailGrid");
            autoWeightDetailGrid.clearRows();
            if(!public_isEmpty(selectValue)){
                for(let obj of customerAutoAgreementDetailList){
                    if(obj.standardTypeId == standardType.weight && obj.goodsTypeId == selectValue){
                        autoWeightDetailGrid.addRow(obj);
                    }
                }
            }
            else {
                for(let obj of customerAutoAgreementDetailList){
                    if(obj.standardTypeId == standardType.volume){
                        autoWeightDetailGrid.addRow(obj);
                    }
                }
            }
        }

        function autoPanelVolumeGoodsTypeIdChange(e){
            let selectValue = e.value;
            // 先清空 grid
            let autoVolumeDetailGrid = mini.get("autoVolumeDetailGrid");
            autoVolumeDetailGrid.clearRows();
            if(!public_isEmpty(selectValue)){
                for(let obj of customerAutoAgreementDetailList){
                    if(obj.standardTypeId == standardType.volume && obj.goodsTypeId == selectValue){
                        autoVolumeDetailGrid.addRow(obj);
                    }
                }
            }
            else {
                for(let obj of customerAutoAgreementDetailList){
                    if(obj.standardTypeId == standardType.volume){
                        autoVolumeDetailGrid.addRow(obj);
                    }
                }
            }
        }


        /**
         * 关闭弹出面板
         */
        function closeAgreementFreightPanel(winId){
            closePanel(winId);
        }

        /**
         * 加载费率
         */

        function loadCustomerAgrement(){
            // actualWeight chargeableWeight
            let actualWeightValue = public_toNumber(actualWeight.getValue(),0);
            if(actualWeightValue<=0){
                showAlert("实际重量不大于零无法加载费率");
                return;
            }
            let chargeableWeightValue = public_toNumber(chargeableWeight.getValue(),0);
            if(chargeableWeightValue<=0){
                showAlert("计费重量不大于零无法加载费率");
                return;
            }

            // 汽运费率加载直接返回
            if(transportSpeciesId.getValue() == transportSpeciesIdData.auto){
                // 调用加载汽运费率
                loadAutoAgrement();
            }
            else{
                // 调用加载空运费率
                loadAirAgrement();
            }

        }


        // 重量标准起票价
        let weightStandardTicketPrice = 0;
        // 体积标准起票价
        let volumeStandardTicketPrice = 0;

        /**
         * 加载空运费率
         */
        function loadAirAgrement(){
            if(isEmpty(destCityId,"目的市")){
                return ;
            }

            if(isEmpty(deliveryCustomerId,"发货人")){
                return ;
            }

            if(isEmpty(airportId,"始发机场")){
                return ;
            }

            if(isEmpty(airlinesId,"航空公司")){
                return ;
            }

            if(isEmpty(flightNo,"班次号")){
                return;
            }

            // 货物类型
            if(isEmpty(goodsTypeId,"货物类型")){
                return;
            }

            if(isNonNumeric(chargeableWeight,"计费重量")){
                return ;
            }
            if(isNonNumeric(volume,"体积")){
                return ;
            }

            // 客户 ID
            let deliveryCustomerIdValue = deliveryCustomerId.getValue();
            // 始发机场 ID
            let airportIdValue = airportId.getValue();
            // 目的市 ID
            let destCityIdValue = destCityId.getValue();
            // 航空公司 ID
            let airlinesIdValue = airlinesId.getValue();
            // 航班名称
            let flightNameValue = flightName.getValue();
            // 货物类型
            let goodsTypeIdValue = goodsTypeId.getValue();
            // 计费重量
            let chargeableWeightValue = public_toNumber(chargeableWeight.getValue());
            // 计费体积
            let volumeValue = public_toNumber(volume.getValue());

            /**
             * customer_id 发货人
             airport_id 始发机场
             city_id  目的市
             airlines_id 航空公司
             flight_no 班次号
             */

            let requestParam = {customerId:deliveryCustomerIdValue, airportId:airportIdValue, cityId:destCityIdValue, airlinesId:airlinesIdValue, flightNo:flightNameValue, goodsTypeId:goodsTypeIdValue, chargeableWeight:chargeableWeightValue, volume:volumeValue};

            let ret = public_getServerData("${base}/pages/customer_manage/freight_agreement/air/loadAirAgrement",requestParam);

            if(ret.ok){
                // 直接填写相应的值
                // weightRate volumeRate
                weightRate.setValue(ret.data.weightRate);
                volumeRate.setValue(ret.data.volumeRate);

                weightStandardTicketPrice = ret.data.weightStandardTicketPrice;
                volumeStandardTicketPrice = ret.data.volumeStandardTicketPrice;

                // 起票价
                ticketPrice.setValue(weightStandardTicketPrice);

                // 同步分摊
                synchronousChange(printWeightRate,weightRate);
                synchronousChange(printVolumeRate,volumeRate);

                // 直接计算运价
                calcTransportCost();
            }
            else{
                showAlert("客户没有设置相应的协议运价");
            }
        }



        /**
         * 加载汽运费率
         */
        function loadAutoAgrement(){

            if(isEmpty(destCityId,"目的市")){
                return ;
            }

            if(isEmpty(deliveryCustomerId,"发货人")){
                return ;
            }

            if(isEmpty(goodsTypeId,"货物类型")){
                return;
            }

            if(isNonNumeric(chargeableWeight,"计费重量")){
                return ;
            }
            if(isNonNumeric(volume,"体积")){
                return ;
            }

            // 客户 ID
            let deliveryCustomerIdValue = deliveryCustomerId.getValue();
            // 目的市 ID
            let destCityIdValue = destCityId.getValue();
            // 货物类型
            let goodsTypeIdValue = goodsTypeId.getValue();
            // 计费重量
            let chargeableWeightValue = public_toNumber(chargeableWeight.getValue());
            // 计费体积
            let volumeValue = public_toNumber(volume.getValue());

            let requestParam = {customerId:deliveryCustomerIdValue, cityId:destCityIdValue, goodsTypeId:goodsTypeIdValue, chargeableWeight:chargeableWeightValue, volume:volumeValue};

            let ret = public_getServerData("${base}/pages/customer_manage/freight_agreement/auto/loadAirAgrement",requestParam);

            if(ret.ok){
                // 直接填写相应的值
                // weightRate volumeRate
                weightRate.setValue(ret.data.weightRate);
                volumeRate.setValue(ret.data.volumeRate);

                weightStandardTicketPrice = ret.data.weightStandardTicketPrice;
                volumeStandardTicketPrice = ret.data.volumeStandardTicketPrice;

                // 同步分摊
                synchronousChange(printWeightRate,weightRate);
                synchronousChange(printVolumeRate,volumeRate);
            }
            else{
                showAlert("客户未设置汽运协议运价!");
            }

        }


        /**
         * 加载客户协议运价标准,如果没有对应的运价标准，给出消息发送，提示相关人员添加
         * 加载条件客户id、始发机场id、航空公司id、目的站id、货物类型id,货物计费重量，货物体积
         * 到b_agreement_freight及b_agreement_freight_standard两张表中做联合检索
         */
        function showCustomerAgrement(){
            // 汽运费率加载直接返回
            if(transportSpeciesId.getValue() == transportSpeciesIdData.auto){
                // 调用显示汽运费率
                showAutoPanel();
            }
            else{
                // 调用显示空运费率
                showAirPanel();
            }
        }

        /**
         * 运费计算
         * 运费合计=计费重量*重量费率>体积*体积费率?计费重量*重量费率:体积*体积费率
         */
        function calcTransportCost(){

            if(isNonNumeric(chargeableWeight,"计费重量")){
                return ;
            }
            if(isNonNumeric(weightRate,"重量费率")){
                return ;
            }
            if(isNonNumeric(volume,"体积")){
                return ;
            }
            if(isNonNumeric(volumeRate,"体积费率")){
                return ;
            }

            let chargeableWeightValue = public_toNumber(chargeableWeight.getValue(),0);
            let volumeValue = public_toNumber(volume.getValue(),0);
            let weightRateValue = public_toNumber(weightRate.getValue(),0);
            let volumeRateValue = public_toNumber(volumeRate.getValue(),0);

            let calcWeightValue = public_round2(chargeableWeightValue * weightRateValue);
            let calcVolumeValue = public_round2(volumeValue * volumeRateValue);

            let flag = 0; // 0 表示使用重量计算出来的价格，1表示使用体积算出来的价格

            let transportCostValue = 0 ;

            if(calcWeightValue > calcVolumeValue){
                transportCostValue = calcWeightValue;
            }
            else{
                transportCostValue = calcVolumeValue;
                flag = 1;
            }

            transportCost.setValue(public_decimal(transportCostValue,0));

            // 注意对比一下起票价,起票价在加载费率时会一并加载，如果不加载费率，起票价是0,所以这个地方就不用加载了,如果加载不到起票价也就不能设置
            if(weightStandardTicketPrice > transportCostValue){
                if(flag==0){
                    let calcWeightRateValue = public_round2(weightStandardTicketPrice/chargeableWeightValue);
                    weightRate.setValue(calcWeightRateValue);
                    // 同步打印值
                    synchronousChange(printWeightRate,weightRate);
                }
                else{
                    let calcVolumeRateValue = public_round2(weightStandardTicketPrice/volumeValue);
                    volumeRate.setValue(calcVolumeRateValue);
                    // 同步打印值
                    synchronousChange(printVolumeRate,volumeRate);

                }

                transportCost.setValue(public_decimal(weightStandardTicketPrice,0));
            }

            // 新增加的
            if(opType=='update'){
                // 计算实收
                calcActualTransportCost();
                // 调用发货人付款方式，计算总金额
                deliveryCustomerPaymentMethodIdChange();
            }
        }

        /**
         * 声明价值数值改变  保险费率数值改变
         */
        function calcInsuranceFee(){
            if(isNonNumeric(declaredValue,"声明价值")){
                declaredValue.setValue(2500);
                return ;
            }
            if(isNonNumeric(insuranceRate,"保险费率")){
                insuranceRate.setValue(0);
                return ;
            }
            let declaredValueValue = public_toNumber(declaredValue.getValue(),-1);
            let insuranceRateValue = public_toNumber(insuranceRate.getValue(),-1);
            insuranceFee.setValue(public_decimal(declaredValueValue * insuranceRateValue/1000,0));

            if(opType == "update"){
                // 计算总费用
                reCalcTotalFee();
            }
        }

        // 添加其他费用
        function addOtherChargesRow(){
            let newRow = {};
            otherChargeDatagrid.addRow(newRow);
            otherChargeDatagrid.beginEditCell(newRow, "name");
        }

        // 删除其他费用
        function removeOtherChargesRow(){
            let rows = otherChargeDatagrid.getSelecteds();
            if (rows.length > 0) {
                otherChargeDatagrid.removeRows(rows, true);
                // 重新计算
                calcOtherCharges();
            }
        }

        // 计算其他费用
        function calcOtherCharges(){
            let otherChargeArray=otherChargeDatagrid.getData();

            if(otherChargeArray.length > 0){
                let otherChargeTotal = 0;
                let otherChargeComment = "";
                let otherChargeFlag = false;
                for(let obj of otherChargeArray){
                    if(public_isEmpty(obj.name)){
                        otherChargeFlag = true;
                        break;
                    }

                    let tempAmount = public_toNumber(obj.amount,-1);

                    if(tempAmount == -1){
                        otherChargeFlag = true;
                        break;
                    }

                    let comment = obj.comment;
                    if(public_isEmpty(comment)){
                        comment="";
                    }

                    otherChargeTotal += tempAmount;
                    otherChargeComment += "{其他费用名目:" + obj.name + ",";
                    otherChargeComment += "金额:" + tempAmount + ",";
                    otherChargeComment += "备注:" + comment + "} ";
                }

                if(!otherChargeFlag){
                    otherCharges.setValue(otherChargeTotal);
                    otherChargesComment.setValue(otherChargeComment);
                    if(opType == "update"){
                        // 计算下总费
                        reCalcTotalFee();
                    }
                }
                else{
                    otherCharges.setValue(0);
                    otherChargesComment.setValue("");
                    showAlert("其他费用列表中 金额 列有非数字值，请修改！")
                }
            }
            else{
                // 清空其他费用金额,及其他费用备注
                otherCharges.setValue(0);
                otherChargesComment.setValue("");
                if(opType == "update"){
                    // 计算下总费
                    reCalcTotalFee();
                }
            }
        }

        /**
         * 计算实收运费  实收运费=运费合计-业务费
         *
         * 实收运费 = 运费合计 + 保费 + 开单送货费 + 税金 + 燃油费 + 其他费用  - 业务费 - 代理送货费
         */
        function calcActualTransportCost(){

            if(isNonNumeric(transportCost,"运费合计")){
                return ;
            }

            if(isNonNumeric(serviceCharge,"业务费")){
                return ;
            }

            let transportCostValue = public_toNumber(transportCost.getValue(),0); // 运费合计
            let insuranceFeeValue = public_toNumber(insuranceFee.getValue(),0); // 保费
            let openBillDeliveryChargeValue = public_toNumber(openBillDeliveryCharge.getValue(),0); // 开单送货费
            let taxValue = public_toNumber(tax.getValue(),0); // 税金
            let fuelSurchargeValue = public_toNumber(fuelSurcharge.getValue(),0); // 燃油费
            let otherChargesValue = public_toNumber(otherCharges.getValue(),0); // 其他费用
            let serviceChargeValue = public_toNumber(serviceCharge.getValue(),0); // 业务费
            let agentDeliveryChargeValue = public_toNumber(agentDeliveryCharge.getValue(),0); // 代理送货费

            let actualTransportCostValue = 0;
            let businessCostAllocationTypeIdValue = businessCostAllocationTypeId.getValue();
            /**
             * 141,140,无分摊,重量
             142,140,重量,重量
             143,140,重量费率,重量费率
             144,140,体积,体积
             145,140,体积费率,体积费率
             */
            if (businessCostAllocationTypeIdValue == 141){
                //  这是业务费用无分摊 实收运费 = 运费合计 + 保费 + 开单送货费 + 税金 + 燃油费 + 其他费用  - 业务费 - 代理送货费
                // 这是业务费用有分摊  实收运费 = 运费合计 + 保费 + 开单送货费 + 税金 + 燃油费 + 其他费用  - 代理送货费
                actualTransportCostValue = public_round2(
                    transportCostValue
                    + insuranceFeeValue
                    + openBillDeliveryChargeValue
                    + taxValue
                    + fuelSurchargeValue
                    + otherChargesValue
                    - serviceChargeValue
                    - agentDeliveryChargeValue);
            }
            else{
                // 这是业务费用有分摊 实收运费 = 运费合计 + 保费 + 开单送货费 + 税金 + 燃油费 + 其他费用  - 代理送货费
                actualTransportCostValue = public_round2(
                    transportCostValue
                    + insuranceFeeValue
                    + openBillDeliveryChargeValue
                    + taxValue
                    + fuelSurchargeValue
                    + otherChargesValue
                    - agentDeliveryChargeValue);
            }
            actualTransportCost.setValue(public_decimal(actualTransportCostValue,0));

            // 新增加的联动计算
            if(opType == "update"){
                // 计算总金额
                deliveryCustomerPaymentMethodIdChange();
            }

        }




        /**
         * 恢复到分摊前的状态
         */
        function shareRecover(isShareStatus){
            synchronousChange(printActualWeight,actualWeight);
            synchronousChange(printChargeableWeight,chargeableWeight);
            synchronousChange(printWeightRate,weightRate);
            synchronousChange(printVolume,volume);
            synchronousChange(printVolumeRate,volumeRate);
            businessCostAllocationId.setValue(isShareStatus);
        }


        /**
         * 业务费用分摊选择
         */
        function serviceChargeShare(){
            if(isEmpty(businessCostAllocationTypeId,"分摊类型")){
                return ;
            }
            let shareIndex = businessCostAllocationTypeId.getValue();

            if(isNonNumeric(serviceCharge,"业务费")){
                return ;
            }
            // 分摊类型
            let shareTypeOption={noShare:141,weight:142,weightRate:143,volume:144,volumeRate:145}
            // 是否分摊
            let yesOrNoShareOption = {yes:11,no:12};
            // 恢复到分摊前的状态
            shareRecover(yesOrNoShareOption.no);

            // 取出需要分摊的业务费用值
            let serviceChargeValue = public_toNumber(serviceCharge.getValue(),-1);
            if(serviceChargeValue<=0 && shareIndex != shareTypeOption.noShare){
                showAlert("业务费用为 0 不能进行分摊操作");
                businessCostAllocationTypeId.setValue(shareTypeOption.noShare);
                return;
            }

            // 不能写switch(shareIndex)，因为表达式值为bool类型
            switch (true) {
                case shareIndex == shareTypeOption.noShare:
                    // 不分摊，恢复原始值
                    break;
                case shareIndex == shareTypeOption.weight:
                    // 按重量分摊
                    serviceChargeShareCalc(chargeableWeight,"计费重量",weightRate,"重量费率",printChargeableWeight,serviceChargeValue);
                    businessCostAllocationId.setValue(yesOrNoShareOption.yes);
                    break;
                case shareIndex == shareTypeOption.weightRate:
                    // 按重量费率分摊
                    serviceChargeShareCalc(weightRate,"重量费率",chargeableWeight,"计费重量",printWeightRate,serviceChargeValue);
                    businessCostAllocationId.setValue(yesOrNoShareOption.yes);
                    break;
                case shareIndex == shareTypeOption.volume:
                    // 按体积分摊
                    serviceChargeShareCalc(volume,"体积",volumeRate,"体积费率",printVolume,serviceChargeValue);
                    businessCostAllocationId.setValue(yesOrNoShareOption.yes);
                    break;
                case shareIndex == shareTypeOption.volumeRate:
                    // 按体积费率分摊
                    serviceChargeShareCalc(volumeRate,"体积费率",volume,"体积",printVolumeRate,serviceChargeValue);
                    businessCostAllocationId.setValue(yesOrNoShareOption.yes);
                    break;
            }

        }

        /**
         * 数值控件非数值判断
         *
         */
        function lengthChange(){
            isNonNumeric(length,"长度");
        }
        function widthChange(){
            isNonNumeric(width,"宽度");
        }
        function heightChange(){
            isNonNumeric(height,"高度");
        }
        function numberPackagesChange(){
            isNonNumeric(numberPackages,"件数");
        }
        function totalNumberChange(){
            isNonNumeric(totalNumber,"总件数");
        }

        function actualWeightChange(){
           let value = isNonNumeric(actualWeight,"实重");
            if(value){
                return;
            }
            synchronousChange(printActualWeight,actualWeight);

            calcTransportCost();
            if(opType == "update"){
                // 调用计算费用
                reCalcTotalFee();
            }

        }

        function chargeableWeightChange(){
           let value = isNonNumeric(chargeableWeight,"计费重量");
            if(value){
                return;
            }
            synchronousChange(printChargeableWeight,chargeableWeight);

            calcTransportCost();
            if(opType == "update"){
                // 调用计算费用
                reCalcTotalFee();
            }
        }
        /**
         * 修改重量费率
         */
        function weightRateChange(e){
            let value = isNonNumeric(weightRate,"重量费率");
            if(value){
                showAlert("重量费率不是数值!");
                // 恢复原始值
                weightRate.setValue(e.oldValue);
                return;
            }

            synchronousChange(printWeightRate,weightRate);
            // 调用计算费用
            calcTransportCost();
            if(opType == "update"){
                reCalcTotalFee();
            }
        }
        function volumeChange(){
           let value = isNonNumeric(volume,"体积");
            if(value){
                return;
            }
            synchronousChange(printVolume,volume);

            // 调用计算费用
            calcTransportCost();
            if(opType == "update"){
                reCalcTotalFee();
            }
        }

        /**
         * 体积费率修改
         */
        function volumeRateChange(){
            let value = isNonNumeric(volumeRate,"体积费率");
            if(!value){
                synchronousChange(printVolumeRate,volumeRate);
            }
        }

        /**
         * 起票价修改
         */
        function ticketPriceChange(e){
            let oldValue = e.oldValue;
            let value = e.value;

            if(!public_isNumber(value)){
                showAlert("修改的起票价不是数值类型，不能修改!",function (){
                    ticketPrice.setValue(oldValue);
                });
                return;
            }

            weightStandardTicketPrice = public_toNumber(e.value);

            // 下面调用重新计算
            calcTransportCost();
            if(opType == "update"){
                reCalcTotalFee();
            }
        }

        /**
         * 重新计算总费用
         */
        function reCalcTotalFee(){
             if(opType='update'){
                 // 计算实收
                 calcActualTransportCost();
                 // 调用发货人付款方式，计算总金额
                 deliveryCustomerPaymentMethodIdChange();
             }
        }

        function openBillDeliveryChargeChange(){
           let flag = isNonNumeric(openBillDeliveryCharge,"开单送货费");
           if(flag){
               return;
           }
           let openBillDeliveryChargeValue = public_toNumber(openBillDeliveryCharge.getValue());
           if(openBillDeliveryChargeValue>0){
               deliveryChargeComment.set({required:true});
           }
           else{
               deliveryChargeComment.set({required:false});

           }

           if(opType == "update"){
               // 重新计算
               reCalcTotalFee();
           }
        }
        function agentDeliveryChargeChange(){
            let flag = isNonNumeric(agentDeliveryCharge,"代理送货费");
            if(flag){
                return;
            }
            let agentDeliveryChargeValue = public_toNumber(agentDeliveryCharge.getValue());
            if(agentDeliveryChargeValue > 0){
                deliveryChargeComment.set({required:true});
            }
            else{
                deliveryChargeComment.set({required:false});
            }

            if(opType == "update"){
                // 重新计算
                reCalcTotalFee();
            }
        }
        function taxChange(){
            let flag = isNonNumeric(tax,"税金");
            if(flag){
                return;
            }
            if(opType == "update"){
                // 重新计算
                reCalcTotalFee();
            }
        }
        function fuelSurchargeChange(){
            let flag = isNonNumeric(fuelSurcharge,"燃油费");
            if(flag){
                return;
            }
            if(opType == "update"){
                // 重新计算
                reCalcTotalFee();
            }
        }
        function collectionMoneyChange(){
            let flag = isNonNumeric(collectionMoney,"代收款");
            if(flag){
                return;
            }
            if(opType == "update"){
                // 重新计算
                reCalcTotalFee();
            }
        }
        function serviceChargeChange(){
            let flag = isNonNumeric(serviceCharge,"业务费");
            if(flag){
                return;
            }
            if(opType == "update"){
                // 重新计算
                reCalcTotalFee();
            }
        }
        function transportCostChange(){
            let flag = isNonNumeric(transportCost,"运费合计");
            if(flag){
                return;
            }
            if(opType == "update"){
                // 重新计算
                reCalcTotalFee();
            }
        }


        /**
         * 选择分摊类型后自动计算业务费用
         * @param objId1
         * @param msg1
         * @param objId2
         * @param msg2
         * @param targetObjId
         * @param serviceChargeValue
         */
        function serviceChargeShareCalc(objId1,msg1,objId2,msg2,targetObjId,serviceChargeValue){
            if(isNonNumeric(objId1,msg1)){
                return;
            }
            if(isNonNumeric(objId2,msg2)){
                return;
            }

            let obj1Value = public_round2(objId1.getValue(),-1);
            let obj2Value = public_round2(objId2.getValue(),-1);

            if(obj1Value<=0 || obj2Value<=0){
                showAlert("分摊操作时，" + msg1 + " 或 " + msg2 + " 不能小于或等于0。");
                return;
            }

            let shareValue = public_round2(obj1Value + serviceChargeValue/obj2Value);

            targetObjId.setValue(shareValue);
        }

        /**
         * 发货人付款方式选择
         */
        function deliveryCustomerPaymentMethodIdChange(){
            if(isEmpty(deliveryCustomerPaymentMethodId,"发货人付款方式")){
                // 1.恢复默认值
                deliveryCustomerPaymentAmount.setValue(0);
                totalAmount.setValue(0);
                actualAmount.setValue(0);
                let totalAmountValue = public_toNumber(totalAmount.getValue(),0);
                let dropAmountValue = public_toNumber(dropAmount.getValue(),0);
                settlementAmount.setValue(public_decimal(totalAmountValue + dropAmountValue,2));
                return ;
            }
            // 计算总金额
            let totalAmountValue = getTotalAmount();
            if(totalAmountValue == -1){
                deliveryCustomerPaymentAmount.setValue(0);
                totalAmount.setValue(0);
                actualAmount.setValue(0);
                let totalAmountValue = public_toNumber(totalAmount.getValue(),0);
                let dropAmountValue = public_toNumber(dropAmount.getValue(),0);
                settlementAmount.setValue(public_decimal(totalAmountValue + dropAmountValue,2));
                return ;
            }
            deliveryCustomerPaymentAmount.setValue(public_decimal(totalAmountValue,0));
            totalAmount.setValue(public_decimal(totalAmountValue,0));
            actualAmount.setValue(public_decimal(totalAmountValue,0));

            let dropAmountValue = public_toNumber(dropAmount.getValue(),0);
            settlementAmount.setValue(public_decimal(totalAmountValue + dropAmountValue,2));

            // 清空收货人付款金额及付款方式
            receiveCustomerPaymentAmount.setValue(0);
            receiveCustomerPaymentAmount.disable();
            receiveCustomerPaymentMethodId.select(0);
        }

        /**
         *  发货人付款金额变化事件处理
         */
        function deliveryCustomerPaymentAmountChange(){
            // 1.判断有没有选择支付方式
            if(isEmpty(deliveryCustomerPaymentMethodId,"发货人支付方式")){
                // 恢复0值
                deliveryCustomerPaymentAmount.setValue(0);
            }
            // 计算总金额
            let totalAmountValue = getTotalAmount();
            if(totalAmountValue == -1){
                deliveryCustomerPaymentAmount.setValue(public_decimal(totalAmount.getValue(),0));
            }

        }

        /**
         * 收货人付款方式
         */
        function receiveCustomerPaymentMethodIdChange(){
            if(isEmptyNoAlert(receiveCustomerPaymentMethodId)){
                // 收货人付款金额设置为0
                receiveCustomerPaymentAmount.setValue(0);
                // 禁用收货人付款金额输入框
                receiveCustomerPaymentAmount.disable();
                if(isEmptyNoAlert(deliveryCustomerPaymentMethodId)){
                    deliveryCustomerPaymentAmount.setValue(0);
                    totalAmount.setValue(0);
                    actualAmount.setValue(0);
                    let totalAmountValue = public_toNumber(totalAmount.getValue(),0);
                    let dropAmountValue = public_toNumber(dropAmount.getValue(),0);
                    settlementAmount.setValue(public_decimal(totalAmountValue + dropAmountValue,2));
                }
                // 把发货人付款金额恢复到总金额
                deliveryCustomerPaymentAmount.setValue(public_decimal(totalAmount.getValue(),0));
                return ;
            }

            // 计算总金额
            let totalAmountValue = getTotalAmount();


            // 获取发货人付款金额
            let deliveryCustomerPaymentAmountValue = public_toNumber(deliveryCustomerPaymentAmount.getValue(),-1);
            // 放开收货人付款金额输入框
            receiveCustomerPaymentAmount.enable();
            let receiveCustomerPaymentAmountValue = public_decimal(totalAmountValue - deliveryCustomerPaymentAmountValue,0);
            // 自动设置发货人付款金额为 总金额 - 收货人付款金额
            receiveCustomerPaymentAmount.setValue(receiveCustomerPaymentAmountValue);

            // 设置结算金额
            let dropAmountValue = public_toNumber(dropAmount.getValue(),0);
            settlementAmount.setValue(public_decimal(totalAmountValue + dropAmountValue,2));

        }

        /**
         * 收货人付款金额变化事件处理
         */
        function receiveCustomerPaymentAmountChange(){
            // 1.判断有没有选择收货人支付方式
            if(isEmpty(receiveCustomerPaymentMethodId,"收货人支付方式")){
                return ;
            }
            if(isNonNumeric(receiveCustomerPaymentAmount,"收货人付款金额")){
                receiveCustomerPaymentAmount.setValue(0);
                return ;
            }

            // 获取发货人付款金额
            let deliveryCustomerPaymentAmountValue = public_toNumber(deliveryCustomerPaymentAmount.getValue(),-1);
            let receiveCustomerPaymentAmountValue = public_toNumber(receiveCustomerPaymentAmount.getValue(),-1);
            let totalAmountValue = getTotalAmount();
            if(totalAmountValue!= public_round2(deliveryCustomerPaymentAmountValue + receiveCustomerPaymentAmountValue)){
                showAlert("发货人付款金额 加 收货人付款金额 不等于 总金额!")
            }
        }

        /**
         * 返回总金额
         * 总金额 = 实收运费 + 业务费 + 代收款 + 保费 + 开单送货费 + 税金 + 燃油费 + 其他费用
         */
        function getTotalAmount() {
            // 总金额=实收运费+业务费+代收款+保费+开单送货费+税金+燃油费+其他费用
            // 实收运费 actualTransportCost
            // 业务费 serviceCharge
            // 代收款 collectionMoney
            // 保费 insuranceFee
            // 开单送货费 openBillDeliveryCharge
            // 税金 tax
            // 燃油费 fuelSurcharge
            // 其他费用 otherCharges
            let totalAmountValue = -1;
            // if (isNonNumeric(actualTransportCost, "实收运费")) {
            //     return totalAmountValue;
            // }
            // let actualTransportCostValue = public_toNumber(actualTransportCost.getValue(), -1);
            //
            // if (isNonNumeric(serviceCharge, "业务费")) {
            //     return totalAmountValue;
            // }
            // let serviceChargeValue = public_toNumber(serviceCharge.getValue(), -1);
            //
            // if (isNonNumeric(collectionMoney, "代收款")) {
            //     return totalAmountValue;
            // }
            // let collectionMoneyValue = public_toNumber(collectionMoney.getValue(), -1);
            //
            // if (isNonNumeric(insuranceFee, "保费")) {
            //     return totalAmountValue;
            // }
            // let insuranceFeeValue = public_toNumber(insuranceFee.getValue(), -1);
            //
            // if (isNonNumeric(openBillDeliveryCharge, "开单送货费")) {
            //     return totalAmountValue;
            // }
            // let openBillDeliveryChargeValue = public_toNumber(openBillDeliveryCharge.getValue(), -1);
            //
            // if (isNonNumeric(tax, "税金")) {
            //     return totalAmountValue;
            // }
            // let taxValue = public_toNumber(tax.getValue(), -1);
            //
            // if (isNonNumeric(fuelSurcharge, "燃油费")) {
            //     return totalAmountValue;
            // }
            // let fuelSurchargeValue = public_toNumber(fuelSurcharge.getValue(), -1);
            //
            // if (isNonNumeric(otherCharges, "其他费用")) {
            //     return totalAmountValue;
            // }
            // let otherChargesValue = public_toNumber(otherCharges.getValue(), -1);

            // 运费合计 = 计费重量 * 重量费率 > 体积 * 体积费率 ？ 计费重量 * 重量费率 : 体积 * 体积费率
            // 实收运费 = 运费合计 - 业务费

            // 总金额 = 发货人付款金额 + 收货人付款金额
            // 实收金额 = 发货人付款金额 + 收货人付款金额 - 业务费 - 代收款 - 结算送货费

            // 总金额 = 实收运费 + 业务费 + 代收款 + 保费 + 开单送货费 + 税金 + 燃油费 + 其他费用


            let transportCostValue = public_toNumber(transportCost.getValue(),0); // 运费合计
            let insuranceFeeValue = public_toNumber(insuranceFee.getValue(),0); // 保费
            let openBillDeliveryChargeValue = public_toNumber(openBillDeliveryCharge.getValue(),0); // 开单送货费
            let taxValue = public_toNumber(tax.getValue(),0); // 税金
            let fuelSurchargeValue = public_toNumber(fuelSurcharge.getValue(),0); // 燃油费
            let otherChargesValue = public_toNumber(otherCharges.getValue(),0); // 其他费用
            let serviceChargeValue = public_toNumber(serviceCharge.getValue(),0); // 业务费
            let agentDeliveryChargeValue = public_toNumber(agentDeliveryCharge.getValue(),0); // 代理送货费
            let collectionMoneyValue = public_toNumber(collectionMoney.getValue(),0); // 代收货款


            let businessCostAllocationTypeIdValue = businessCostAllocationTypeId.getValue();

            if (businessCostAllocationTypeIdValue == 141) {
                // 无分摊
                // 总金额 或 发货人付款金额  =  运费合计 + 保费 + 开单送货费 + 税金 + 燃油费 + 其他费用  + 代收货款
                // 有分摊
                // 总金额 或 发货人付款金额  =  运费合计 + 保费 + 开单送货费 + 税金 + 燃油费 + 其他费用 + 业务费 + 代收货款
                totalAmountValue = public_round2(
                    transportCostValue
                    + insuranceFeeValue
                    + openBillDeliveryChargeValue
                    + taxValue
                    + fuelSurchargeValue
                    + otherChargesValue
                    + collectionMoneyValue);
            }
            else{
                // 有分摊
                // 总金额  =  运费合计 + 保费 + 开单送货费 + 税金 + 燃油费 + 其他费用 + 业务费 + 代收货款
                totalAmountValue = public_round2(
                    transportCostValue
                    + insuranceFeeValue
                    + openBillDeliveryChargeValue
                    + taxValue
                    + fuelSurchargeValue
                    + otherChargesValue
                    + serviceChargeValue
                    + collectionMoneyValue
                );
            }


            return totalAmountValue;
        }


        /**
         * 根据传入的控件对象id,获取相应的值，如果为-1表示其为非数值，则返回true,如果是数值则返回false
         * @param objId
         * @param msg
         * @returns {boolean}
         */
        function isNonNumeric(obj,msg){
            let objValue = public_toNumber(obj.getValue(),-1);
            if(objValue==-1){
                showAlert(msg + " 不能是非数值!");
                return true;
            }
            return false;
        }

        /**
         * 根据传入的控件对象,获取相应的值，如果为null或"",则返回true 否则返回false
         * @param ObjId
         * @param msg
         * @returns {boolean}
         */
        function isEmpty(obj,msg){
            let objValue = public_isEmpty(obj.getValue());
            if(objValue){
                showAlert("没有选择或没有填写 " + msg + " !");
                return true;
            }
            return false;
        }

        function isEmptyNoAlert(obj){
            let objValue = public_isEmpty(obj.getValue());
            if(objValue){
                return true;
            }
            return false;
        }

        /**
         * 同步目标对象中的值与源对象中的值一样
         * @param targetObj
         * @param sourceObj
         */
        function synchronousChange(targetObj,sourceObj){
            targetObj.setValue(sourceObj.getValue());
        }

        /**
         * 保存分单
         */
        function saveBill(updateSave){
            billForm.validate();
            if (billForm.isValid() == false){
                return;
            }

            // 判断几个关键数据要大于零
            // 1.运输费用
            // 2.总费用
            // 3.总数据
            // actualWeight chargeableWeight  let transportCost let actualTransportCost let totalAmount  actualAmount
            let actualWeightValue = public_toNumber(actualWeight.getValue(),0);
            if(actualWeightValue<=0){
                showAlert("实际重量不大于零，不能保存!");
                return;
            }
            let chargeableWeightValue = public_toNumber(chargeableWeight.getValue(),0);
            if(chargeableWeightValue<=0){
                showAlert("计费重量不大于零，不能保存!");
                return;
            }
            let transportCostValue = public_toNumber(transportCost.getValue(),0);
            if(transportCostValue<=0){
                showAlert("运费合计不大于零，不能保存!");
                return;
            }
            // let actualTransportCostValue = public_toNumber(actualTransportCost.getValue(),0);
            // if(actualTransportCostValue<=0){
            //     showAlert("实收运费不大于零，不能保存!");
            //     return;
            // }
            let totalAmountValue = public_toNumber(totalAmount.getValue(),0);
            if(totalAmountValue<=0){
                showAlert("总金额不大于零，不能保存!");
                return;
            }
            let actualAmountValue = public_toNumber(actualAmount.getValue(),0);
            if(actualAmountValue<=0){
                showAlert("实收金额不大于零，不能保存!");
                return;
            }

            if(!updateSave){
                if(opType!="add"){
                    // 定义配载状态
                    let billLoadStatus = {noLoad:351,partLoad:352,allLoad:353};
                    let billLoadStatusIdValue = mini.get("billLoadStatusId").getValue();
                    if(billLoadStatusIdValue != billLoadStatus.noLoad){
                        showAlert("分单不是未配载状态，不能更新!");
                        return;
                    }
                }
            }

            //提交数据
            let billPojo = billForm.getData(true);
            // 获取其他费用列表
            let otherChargeList=otherChargeDatagrid.getData();
            billPojo.otherChargeList = otherChargeList;

            mini.confirm(
                "确定保存分单?",
                "分单保存",
                function(action) {
                    if (action == "ok") {
                        let opUrl ="";
                        if(opType=="add"){
                            opUrl="${base}/pages/native_bill_manage/addNativeBill";
                        }
                        else{
                            if(!updateSave){
                                opUrl="${base}/pages/native_bill_manage/updateNativeBill";
                            }
                            else{
                                // 更新非数值信息
                                opUrl="${base}/pages/native_bill_manage/updateSaveNativeBill";
                            }
                        }
                        let ret = public_getServerData(opUrl,billPojo);

                        showAlert(ret.message,function () {
                           if(ret.ok){
                               if(opType == "add"){
                                   // 刷新当前页面
                                   window.location.reload();
                               }
                               else{
                                   // 关闭编辑页面
                                   parent.window.closeActiveTab();
                               }
                           }
                        });
                    }
                });

        }

        /**
         * 打印分单
         */
        function printBill(){

            // 分单插入成功，则清空当前表单
            // billForm.clear();
            // 清空其他费用列表
            // otherChargeDatagrid.clearRows();
            // 设置默认值
            // setDefaultValue();
            // 恢复空运界面
            // transportSpeciesIdChange();
            // 清空航班下拉列有数据
            // flightNo.load({});




        }


        /**
         * 统一设置默认值
         */
        function setDefaultValue(){
            setObjValue(transportSpeciesId,0,false);
            setObjValue(transportWayId,0,false);
            setObjValue(transportScopeId,0,false);
            setObjValue(goodsTypeId,0,false);
            setObjValue(businessCostAllocationTypeId,0,false);

            setObjValue(totalNumber,0);
            setObjValue(actualWeight,0);
            setObjValue(chargeableWeight,0);
            setObjValue(volume,0);
            setObjValue(weightRate,0);
            setObjValue(volumeRate,0);
            setObjValue(transportCost,0);
            setObjValue(declaredValue,2500);
            setObjValue(insuranceRate,0);
            setObjValue(insuranceFee,0);
            setObjValue(openBillDeliveryCharge,0);
            setObjValue(agentDeliveryCharge,0);
            setObjValue(tax,0);
            setObjValue(fuelSurcharge,0);
            setObjValue(collectionMoney,0);
            setObjValue(otherCharges,0);
            setObjValue(serviceCharge,0);
            setObjValue(actualTransportCost,0);
            setObjValue(printActualWeight,0);
            setObjValue(printChargeableWeight,0);
            setObjValue(printWeightRate,0);
            setObjValue(printVolume,0);
            setObjValue(printVolumeRate,0);
            setObjValue(innerOperationCharge,0);
            setObjValue(deliveryCustomerPaymentAmount,0);
            setObjValue(receiveCustomerPaymentAmount,0);
            setObjValue(totalAmount,0);
            setObjValue(actualAmount,0);

            /**
             * billLoadStatusId = {Long@11698} 351
             businessCostStatusId = {Long@11699} 321
             agentDeliveryChargeStatusId = {Long@11700} 321
             arrearsStatusId = {Long@11701} 321
             dropStatusId = {Long@11702} 361
             settlementStatusId = {Long@11703} 321
             refundNumber = {Integer@11704} 0
             refundActualWeight = {Double@11705} 0.0
             refundChargeableWeight = {Double@11706} 0.0
             refundVolume = {Double@11707} 0.0
             dropAmount = {Double@11708} 0.0
             settlementAmount = {Double@11709} 0.0
             shareCost = {Double@11710} 0.0
             operatingCost = {Double@11711} 0.0
             grossProfit = {Double@11712} 0.0
             */
            setObjValue(mini.get("billLoadStatusId"),351);
            setObjValue(mini.get("businessCostStatusId"),321);
            setObjValue(mini.get("agentDeliveryChargeStatusId"),321);
            setObjValue(mini.get("arrearsStatusId"),321);
            setObjValue(mini.get("dropStatusId"),361);
            setObjValue(mini.get("settlementStatusId"),321);
            setObjValue(mini.get("refundNumber"),0);
            setObjValue(mini.get("refundActualWeight"),0.0);
            setObjValue(mini.get("refundChargeableWeight"),0.0);
            setObjValue(mini.get("refundVolume"),0.0);
            setObjValue(mini.get("dropAmount"),0.0);
            setObjValue(mini.get("settlementAmount"),0.0);
            setObjValue(mini.get("shareCost"),0.0);
            setObjValue(mini.get("operatingCost"),0.0);
            setObjValue(mini.get("grossProfit"),0.0);

            // setObjValue(cashierId,"${casherId!}");
            setObjValue(openBillUserId,"${loginUserId!}");
            setObjValue(openBillDepartmentId,"${depId!}");
            setObjValue(rollCallDepartmentId,"${depId!}");
            setObjValue(cityId,"${cityId!}");
            setObjValue(cityName,"${cityName!}");
            setObjValue(openBillDate,"${openBillDate!}");
        }

        /**
         * 设置控制值，要根据控制类型进行判断，调用不同的方法
         */
        function setObjValue(objId,value,selectType){
            let objType = objId.type;
            /*
            combobox
            textbox
            hidden
            autocomplete
            datepicker
            textarea
            button
            datagrid
             */
            if(objType=="combobox" || objType == "autocomplete"){
                if(value.length>4){
                    objId.setValue(value);
                }
                else{
                    objId.select(value);
                }
            }
            else{
                objId.setValue(value);
            }
        }
        
        function showReceiveCustomerPanel() {


            // 控制收货人按钮是否可以点击
            if(public_isEmpty(deliveryCustomerId.getValue())){
                showAlert("选择【发货人】后才可以选择【收货人】!");
                return;
            }
            //receiveCustomerName  receiveCustomerPhone  receiveCustomerAddress
            receiveCustomerName.set({enabled:true});
            receiveCustomerPhone.set({enabled:true});
            receiveCustomerAddress.set({enabled:true});

            mini.get("queryDeliveryCustomerId").setValue(deliveryCustomerId.getValue());
            // 显示收货人面板
            public_showModelAtPos("receiveCustomerPanel", "center", "middle");

            queryReceive();
        }
        
        function queryReceive() {

            let form = new mini.Form("#queryReceiveCustomerForm");
            let data = form.getData(true);
            mini.get("receiveCustomerPanelDatagrid").load(data);
        }


        function selectReceiveCustomer() {
            let datagrid = mini.get("receiveCustomerPanelDatagrid");
            let selectedItem = datagrid.getSelected();

            if(public_isEmpty(selectedItem)){
                showAlert("没有选择收货人或无收货人可以选择!");
                return;
            }

            receiveCustomerName.setValue(selectedItem.receiveCustomerName);
            receiveCustomerPhone.setValue(selectedItem.receiveCustomerPhone);
            receiveCustomerAddress.setValue(selectedItem.receiveCustomerAddress);

            closeReceiveCustomerPanel("receiveCustomerPanel");
        }


        /**
         * 收货人选择面板
         */
        function closeReceiveCustomerPanel(winId){
            mini.get("queryDeliveryCustomerId").setValue("");
            closePanel(winId);
        }

        function closePanel(winId){
            let winObj = mini.get(winId);
            winObj.hide();
        }

        /**
         * 打印数据初始化
         */
        function printDataInit(){

            <!-- 分单归属部门 attributionDepartmentId -->
            $("#billPrintAttributionDepartmentName").text(attributionDepartmentId.getText());

            // 第一行
            // 始发站
            $("#billPrintCityName").text(cityName.getValue());
            // 目的站
            $("#billPrintDestCityName").text(destCityId.getText());
            // 运输方式
            $("#billPrintTransportSpeciesName").text(transportSpeciesId.getText());
            // 提货方式
            $("#billPrintPickUpGoodsWayName").text(pickUpGoodsWayId.getText());

            // 第二行
            // 发货人
            $("#billPrintDeliveryCustomerName").text(deliveryCustomerName.getValue());
            $("#billPrintDeliveryCustomerPhone").text(deliveryCustomerPhone.getValue());
            $("#billPrintDeliveryCustomerAddress").text(deliveryCustomerAddress.getValue());

            // 收货人
            $("#billPrintReceiveCustomerName").text(receiveCustomerName.getValue());
            $("#billPrintReceiveCustomerPhone").text(receiveCustomerPhone.getValue());
            $("#billPrintReceiveCustomerAddress").text(receiveCustomerAddress.getValue());

            // 第三行
            // 货物名称
            let goodsNameValue = goodsName.getValue();
            let packingWayIdNameValue = packingWayId.getText();
            $("#billPrintGoodsName").text(goodsNameValue + "/" + packingWayIdNameValue);
            // 件数
            $("#billPrintTotalNumber").text(totalNumber.getValue());
            // 实重
            $("#billPrintActualWeight").text(printActualWeight.getValue());
            // 计费重量
            $("#billPrintChargeableWeight").text(printChargeableWeight.getValue());
            // 体积
            $("#billPrintVolume").text(printVolume.getValue());

            // 班次/日期
            $("#billPrintFlightDate").text(flightDate.getFormValue());
            let fName = flightName.getText();
            let fPlanTime = planTakeOffTime.getValue();
            $("#billPrintFlightName").text(fName + "/" + fPlanTime);

            // 提货点姓名、地址、电话号码
            $("#billPrintPickUpPointName").text(pickUpPointName.getValue());
            $("#billPrintPickUpPointPhone").text(pickUpPointPhone.getValue());
            $("#billPrintPickUpPointAddress").text(pickUpPointAddress.getValue());

            // 第四行
            // 费率 weightRate(重量费率) printWeightRate   volumeRate(体积费率) printVolumeRate
            $("#billPrintWeightRate").text(printWeightRate.getValue());

            // 运费合计
            // printChargeableWeight  printWeightRate  printVolume  printVolumeRate
            let printChargeableWeightValue = printChargeableWeight.getValue();
            let printWeightRateValue = printWeightRate.getValue();
            let printVolumeValue = printVolume.getValue();
            let printVolumeRateValue = printVolumeRate.getValue();

            let value1 = public_decimal(printChargeableWeightValue * printWeightRateValue,0);
            let value2 = public_decimal(printVolumeValue * printVolumeRateValue,0);

            let printTransportCost = value1 > value2 ? value1 : value2;

            if(printWeightRateValue == 0){
                $("#billPrintWeightRate").text("");
            }

            if(printTransportCost == 0){
                printTransportCost = transportCost.getValue();
            }

            $("#billPrintTransportCost").text(printTransportCost);
            // 代收货款
            $("#billPrintCollectionMoney").text(collectionMoney.getValue());
            // 开单送货费
            $("#billPrintOpenBillDeliveryCharge").text(openBillDeliveryCharge.getValue());
            // 声明价值
            $("#billPrintDeclaredValue").text(declaredValue.getValue());
            // 保费 insuranceRate(保险费率) insuranceFee(保费)
            $("#billPrintInsuranceFee").text(insuranceFee.getValue());
            // 燃油费
            $("#billPrintFuelSurcharge").text(fuelSurcharge.getValue());
            // 其他费用
            $("#billPrintOtherCharges").text(otherCharges.getValue());
            // 总额
            $("#billPrintTotalAmount").text(totalAmount.getValue());
            // 发货人付款方式
            let deliveryCustomerPaymentMethodIdValue = deliveryCustomerPaymentMethodId.getText();
            if(public_isEmpty(deliveryCustomerPaymentMethodIdValue)){
                $("#billPrintDeliveryCustomerPaymentMethod").text("");
                $("#billPrintDeliveryCustomerPaymentMethod1").text("");
                $("#billPrintDeliveryCustomerPaymentAmount").text("");
            }
            else{
                $("#billPrintDeliveryCustomerPaymentMethod").text(deliveryCustomerPaymentMethodId.getText());
                $("#billPrintDeliveryCustomerPaymentAmount").text(deliveryCustomerPaymentAmount.getValue());
            }

            // 收货人付款方式
            let receiveCustomerPaymentMethodIdValue = receiveCustomerPaymentMethodId.getValue();
            if(public_isEmpty(receiveCustomerPaymentMethodIdValue)){
                $("#billPrintReceiveCustomerPaymentMethod").text("");
                $("#billPrintReceiveCustomerPaymentMethod1").text("");
                $("#billPrintReceiveCustomerPaymentAmount").text("");
            }else{
                $("#billPrintReceiveCustomerPaymentMethod").text(receiveCustomerPaymentMethodId.getText());
                $("#billPrintReceiveCustomerPaymentAmount").text(receiveCustomerPaymentAmount.getValue());
            }

            // 第五行
            // 备注
            $("#billPrintComment").text(comment.getValue());

            // 第六行
            // 填开时间

            $("#billPrintBillLoadMasterBillIds").text("提货单号:" + mini.get("billLoadMasterBillIds").getFormValue());

            $("#billPrintOpenBillDate").text(openBillDate.getFormValue());
            // 填开地点
            $("#billPrintCityName1").text(cityName.getValue());
            // 填开人
            $("#billPrintOpenBillUserName").text(openBillUserId.getText());
        }

        /**
         * 弹出打印面板
         */
        function showPrintBill(){
            getPrinterlist("printList");

            // 获取要显示在打印页面上的数据
            printDataInit();

            public_showModelAtPos("billPrintPanel", "center", "middle");
        }

        /**
         */
        function showPrintLabel(){

            let totalNumberValue = totalNumber.getValue();

            let startIndex = mini.get("startIndex");
            let endIndex = mini.get("endIndex");

            startIndex.set({minValue:1,maxValue:totalNumberValue,value:1});
            endIndex.set({minValue:1,maxValue:totalNumberValue,value:totalNumberValue});

            // 加载打印机列表
            getPrinterlist("labelPrinterList");

            public_showModelAtPos("billLabelPrintPanel", "center", "middle");
        }


        /**
         * 根据ID加载打印机列表
         */
        function getPrinterlist(printerId) {
            let printList = $("#"+printerId); //打印机下拉列表
            // 清空下拉列表
            printList.empty();
            printList.prepend("<option value='-1'>请选择</option>");

            let lodop = getLodop($("#LODOP_OB"),$("#LODOP_EM"));

            let printerAccount = lodop.GET_PRINTER_COUNT();

            for (let i = 0; i < printerAccount; i++) {
                let printerIndex = i.toString();
                let printerName = lodop.GET_PRINTER_NAME(i);
                printList.append("<option value='" + printerIndex + "'>" + printerName + "</option>");
            }
        }

        /**
         * 打印
         * @param opType
         */
        function printPage(opType){

            let selectedPrinterName = $("#printList").find("option:selected").text();;
            if(public_isEmpty(selectedPrinterName) || selectedPrinterName=="请选择"){
                showAlert("请选择指定打印机!");
                return;
            }

            let LODOP = getLodop($("#LODOP"), $("#LODOP_EM"));
            //lodop.PRINT_INIT("打印详细信息");
            //lodop.PRINT_INITA(-107, -90, 800, 600, "套打EMS的模板");
            //lodop.SET_PRINT_PAGESIZE(1, "90mm", "55mm", ""); //设置纸张高度

            LODOP.PRINT_INIT("分单票打印");
            LODOP.SET_PRINT_PAGESIZE(1, "210mm", "144mm", ""); //设置纸张高度

            // 第一行
            // 始发站
            LODOP.ADD_PRINT_TEXT("21mm", "27mm", "25mm", "4mm", $("#billPrintCityName").text()); // 内容，参数（上边距,左边距，内容显示宽度，内容显示高度）
            // 目的站
            LODOP.ADD_PRINT_TEXT("21mm", "70mm", "25mm", "4mm", $("#billPrintDestCityName").text());
            // 运输方式
            LODOP.ADD_PRINT_TEXT("21mm", "128mm", "25mm", "4mm", $("#billPrintTransportSpeciesName").text());
            // 提货方式
            LODOP.ADD_PRINT_TEXT("21mm", "173mm", "25mm", "4mm", $("#billPrintPickUpGoodsWayName").text());

            // 第二行
            // 发货人
            LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);

            LODOP.ADD_PRINT_TEXT("36mm", "15mm", "85mm", "4mm", $("#billPrintDeliveryCustomerName").text());// 内容，参数（上边距,左边距，内容显示宽度，内容显示高度）
            LODOP.ADD_PRINT_TEXT("41mm", "15mm", "85mm", "4mm", $("#billPrintDeliveryCustomerPhone").text());
            LODOP.ADD_PRINT_TEXT("46mm", "15mm", "185mm", "4mm", $("#billPrintDeliveryCustomerAddress").text());

            // 收货人
            LODOP.ADD_PRINT_TEXT("36mm", "110mm", "85mm", "4mm", $("#billPrintReceiveCustomerName").text());
            LODOP.ADD_PRINT_TEXT("41mm", "110mm", "85mm", "4mm", $("#billPrintReceiveCustomerPhone").text());
            LODOP.ADD_PRINT_TEXT("46mm", "110mm", "185mm", "4mm", $("#billPrintReceiveCustomerAddress").text());


            // 第三行
            // 品名包装
            LODOP.ADD_PRINT_TEXT("69mm", "15mm", "25mm", "4mm", $("#billPrintGoodsName").text());  // 内容，参数（上边距,左边距，内容显示宽度，内容显示高度）
            // 件数
            LODOP.ADD_PRINT_TEXT("69mm", "44mm", "20mm", "4mm", $("#billPrintTotalNumber").text());
            // 实重
            LODOP.ADD_PRINT_TEXT("69mm", "58mm", "20mm", "4mm", $("#billPrintActualWeight").text());
            // 计重
            LODOP.ADD_PRINT_TEXT("69mm", "74mm", "20mm", "4mm", $("#billPrintChargeableWeight").text());
            // 体积
            LODOP.ADD_PRINT_TEXT("69mm", "95mm", "20mm", "4mm", $("#billPrintVolume").text());

            // 班次/日期
            LODOP.ADD_PRINT_TEXT("65mm", "112mm", "20mm", "4mm", $("#billPrintFlightDate").text());
            LODOP.ADD_PRINT_TEXT("70mm", "112mm", "24mm", "4mm", $("#billPrintFlightName").text()); // 内容，参数（上边距,左边距，内容显示宽度，内容显示高度）

            // 提货点
            LODOP.ADD_PRINT_TEXT("65mm", "135mm", "60mm", "4mm", $("#billPrintPickUpPointName").text());
            LODOP.ADD_PRINT_TEXT("70mm", "135mm", "60mm", "4mm", $("#billPrintPickUpPointAddress").text());
            LODOP.ADD_PRINT_TEXT("75mm", "135mm", "100mm", "4mm", $("#billPrintPickUpPointPhone").text());

            // 第四行

            // 费率 weightRate(重量费率) printWeightRate   volumeRate(体积费率) printVolumeRate
            LODOP.ADD_PRINT_TEXT("88mm", "14mm", "20mm", "4mm", $("#billPrintWeightRate").text());
            // 运费合计
            LODOP.ADD_PRINT_TEXT("88mm", "25mm", "20mm", "4mm", $("#billPrintTransportCost").text()); // 内容，参数（上边距,左边距，内容显示宽度，内容显示高度）
            // 代收货款
            LODOP.ADD_PRINT_TEXT("88mm", "45mm", "20mm", "4mm", $("#billPrintCollectionMoney").text());
            // 开单送货费
            LODOP.ADD_PRINT_TEXT("88mm", "53mm", "20mm", "4mm", $("#billPrintOpenBillDeliveryCharge").text());
            // 声明价值
            LODOP.ADD_PRINT_TEXT("88mm", "93mm", "20mm", "4mm", $("#billPrintDeclaredValue").text());  // 内容，参数（上边距,左边距，内容显示宽度，内容显示高度）
            // 保费 insuranceRate(保险费率) insuranceFee(保费)
            LODOP.ADD_PRINT_TEXT("88mm", "113mm", "20mm", "4mm", $("#billPrintInsuranceFee").text());
            // 燃油费
            LODOP.ADD_PRINT_TEXT("88mm", "129mm", "20mm", "4mm", $("#billPrintFuelSurcharge").text());
            // 其他费用
            LODOP.ADD_PRINT_TEXT("88mm", "144mm", "20mm", "4mm", $("#billPrintOtherCharges").text());
            // 总额
            LODOP.ADD_PRINT_TEXT("88mm", "163mm", "20mm", "4mm", $("#billPrintTotalAmount").text());
            // 发货人付款方式
            LODOP.ADD_PRINT_TEXT("88mm", "182mm", "40mm", "4mm", $("#billPrintDeliveryCustomerPaymentMethod").text() + " " + $("#billPrintDeliveryCustomerPaymentAmount").text());
            LODOP.ADD_PRINT_TEXT("92mm", "182mm", "40mm", "4mm", $("#billPrintReceiveCustomerPaymentMethod").text() + " " + $("#billPrintReceiveCustomerPaymentAmount").text());

            // 第五行
            // 备注
            LODOP.ADD_PRINT_TEXT("97mm", "50mm", "100mm", "10mm", $("#billPrintComment").text());


            // 分单归属部门
            LODOP.ADD_PRINT_TEXT("97mm", "160mm", "40mm", "10mm", $("#billPrintAttributionDepartmentName").text());


            // 第六行
            //提货单号  这个还没有处理，基本原则是分单配载显示正单号否则显示分单号
            LODOP.ADD_PRINT_TEXT("120mm", "15mm", "45mm", "10mm", $("#billPrintBillLoadMasterBillIds").text());  // 内容，参数（上边距,左边距，内容显示宽度，内容显示高度）
            // 填开时间
            LODOP.ADD_PRINT_TEXT("120mm", "144mm", "20mm", "4mm", $("#billPrintOpenBillDate").text());  // 内容，参数（上边距,左边距，内容显示宽度，内容显示高度）
            // 填开地点
            LODOP.ADD_PRINT_TEXT("120mm", "165mm", "20mm", "4mm", $("#billPrintCityName1").text());
            // 填开人
            LODOP.ADD_PRINT_TEXT("120mm", "179mm", "20mm", "4mm", $("#billPrintOpenBillUserName").text());


            if (opType == "1") {
                LODOP.SET_PRINTER_INDEXA(selectedPrinterName)
                LODOP.PRINT(); //直接打印
            }else if (opType == "2") {
                LODOP.SET_PRINTER_INDEXA(selectedPrinterName)
                LODOP.PREVIEW(); //打印预览
            }else if (opType == "3") {
                LODOP.PRINT_SETUP(); //打印维护
            }


        }

        /**
         * 生成标签
         */
        function generateBillLabel(){
            let labelDatagrid1 = mini.get("labelDatagrid1");
            let startIndex = mini.get("startIndex");
            let endIndex = mini.get("endIndex");
            let startIndexValue = startIndex.getValue();
            let endIndexValue = endIndex.getValue();
            let cardUrl = "${base}/pages/native_bill_manage/generateBillLabel?";
            cardUrl += "billId=" + mini.get("id").getValue() + "&";
            cardUrl += "startIndex=" + startIndexValue + "&";
            cardUrl += "endIndex=" + endIndexValue + "&";
            labelDatagrid1.setUrl(cardUrl);
            labelDatagrid1.load();
        }


        function cardItemRenderer(record, rowIndex, meta, grid){
            meta.rowCls = "item";
            let html =
                '<div class="flexcolumn" style="width:400px;">'
                    + '<div class="flexrow center width100 fontsize20 height30">'
                        + '<div style="font-weight: bold;font-family: 黑体">' + record.companyName + '</div>'
                        + '<div class="height30" style="display: flex;flex-direction: column-reverse ;justify-content: end;align-items: flex-end;">'
                            + '<span class="fontsize8 mgleft10" style="font-weight: bold;font-family: 黑体" >' + record.companyPhone + '</span>'
                        + '</div>'
                    + '</div>'

                    + '<div class="border flexrow width100" style="margin-bottom: none;">'
                        + '<div class="flexrow width50">'
                            + '<div class="flexcolumn center height45" style="width:20%;">'
                                + '<div class="fontsize8">分</div><div class="fontsize8">单</div><div class="fontsize8">号</div>'
                            + '</div>'
                            + '<div class="border flexrow center fontsize15 height45" style="width:80%;border-top: none; border-bottom: none;">' + record.billId + '</div>'
                        + '</div>'
                        + '<div class="flexrow center width50 height45 fontsize20">' + record.transportSpeciesIdName + '</div>'
                    + '</div>'

                    + '<div class="border flexrow width100" style="margin-bottom: none;border-top: none;">'
                        + '<div class="flexrow width50">'
                            + '<div class="flexcolumn center height45" style="width: 20%;">'
                                + '<div class="fontsize8">始</div> <div class="fontsize8">发</div> <div class="fontsize8">站</div>'
                            + '</div>'
                            + '<div class="border flexrow center height45 fontsize15" style="width:80%;border-top: none; border-bottom: none;">' + record.cityIdName + '</div>'
                        + '</div>'

                        + '<div class="flexrow width50">'
                            + '<div class="flexcolumn center height45" style="width: 20%;">'
                                + '<div class="fontsize8">目</div><div class="fontsize8">的</div><div class="fontsize8">站</div>'
                            + '</div>'
                            + '<div class="border flexrow center height45" style="font-size: 15pt;width:80%;border-top: none; border-bottom: none;border-right: none;">' + record.destCityIdName + '</div>'
                        + '</div>'
                    + '</div>'

                    + '<div class="border flexrow width100" style="border-top: none">'
                        + '<div class="border fontsize10" style="width:15%;border-top: none; border-bottom: none; border-left: none;padding-left: 5px;">收货人</div>'
                        + '<div class="fontsize10"  style="width: 80%;">' +  record.receiveCustomerName  + '</div>'
                    + '</div>'
                + '</div>'

                + '<div class="flexrow" style="width:400px;margin-top: 2px;" >'
                    + '<img src="' + record.qrcodeUrl + '" style="width:50px; height:50px; margin-left: 5px;" alt="aaa" />'
                    + '<div class="flexcolumn" style="width: 350px;height: 50px;justify-content: center;align-items: center;">'
                        + '<div >'
                            + '<span  style="font-size: 16pt;">' + record.totalNumber +  '</span><span class="fontsize15" style="margin-left: 5px;">第</span><span class="fontsize10">' + record.sequence + '</span><span class="fontsize15">件</span>'
                        + '</div>'
                        + '<div class="fontsize10">'
                            + '<span style="font-size: 16pt;">' + record.flightNoName + '</span><span class="fontsize15" style="margin-left: 5px;margin-right: 5px;">' + record.flightDate + '</span> <span class="fontsize15">' + record.flightPlanTime + '</span>'
                        + '</div>'
                    + '</div>'
                + '</div>';
            return html;
        }


        /**
         * 获取打印数据
         */
        function loadLabelData(){
            let startIndex = mini.get("startIndex");
            let endIndex = mini.get("endIndex");
            let startIndexValue = startIndex.getValue();
            let endIndexValue = endIndex.getValue();
            let cardUrl = "${base}/pages/native_bill_manage/generateBillLabel?";
            cardUrl += "billId=" + mini.get("id").getValue() + "&";
            cardUrl += "startIndex=" + startIndexValue + "&";
            cardUrl += "endIndex=" + endIndexValue;
            let labelData = public_getServerData(cardUrl);
            return labelData;
        }


        /**
         * 标签卡片渲染
         * objMap.put("companyName",this.companyName);
         * objMap.put("companyPhone",this.companyPhone);
         objMap.put("billId",billId);
         objMap.put("transportSpeciesIdName",transportSpeciesIdName);
         objMap.put("cityIdName",cityIdName);
         objMap.put("destCityIdName",destCityIdName);
         objMap.put("receiveCustomerName",receiveCustomerName);
         objMap.put("totalNumber",totalNumber);
         objMap.put("sequence",i);
         objMap.put("flightNoName",flightNoName);
         objMap.put("flightDate",flightDate);
         objMap.put("flightPlanTime",flightPlanTime);

         {total:11,
             data:[
            ]}
         */

        function printLabel(opType) {

            let selectedPrinterName = $("#labelPrinterList").find("option:selected").text();;
            if(public_isEmpty(selectedPrinterName) || selectedPrinterName == "请选择"){
                showAlert("请选择指定打印机!");
                return;
            }

            let LODOP = getLodop($('#LODOP'), $('#LODOP_EM'));
            LODOP.PRINT_INITA(0, 0, 800, 600, "标签打印");
            LODOP.SET_PRINT_PAGESIZE(1, "90mm", "55mm", ""); //设置纸张高度

            // 加载二维码数据
            let labelData = loadLabelData();

            let startIndex = mini.get("startIndex");
            let endIndex = mini.get("endIndex");
            let startIndexValue = startIndex.getValue();
            let endIndexValue = endIndex.getValue();

            for(let index = 0;index < labelData.data.length; index++){
                let obj = labelData.data[index];


                console.log(obj.companyName);

                // 1.输出 公司名
                LODOP.ADD_PRINT_TEXT("3mm", "20mm", "40mm", "10mm", obj.companyName);  // 参数 ADD_PRINT_TEXT(Top,Left,contentWidth,contentHeight,strContent)
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 18);
                LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "LetterSpacing", 2);

                // 输出公司电话
                LODOP.ADD_PRINT_TEXT("6mm", "45mm", "40mm", "5mm", obj.companyPhone); // 参数 ADD_PRINT_TEXT(Top,Left,contentWidth,contentHeight,strContent)
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 8);
                LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "LetterSpacing", 1);

                // 输出一个矩形,及其相应的分隔线
                LODOP.ADD_PRINT_RECT("12mm", "1mm", "86mm", "41mm", 0, 1);  //(top,left,width,height,0,1--线宽) OK
                // 第一条横线
                LODOP.ADD_PRINT_LINE("24mm", "1mm", "24mm", "87mm", 0, 1);  //(leftx,lefty,rightx,righty) OK
                // 第二条横线
                LODOP.ADD_PRINT_LINE("36mm", "1mm", "36mm", "87mm", 0, 1);

                // 运单号与始发站纵线
                LODOP.ADD_PRINT_LINE("12mm", "6mm", "36mm", "6mm", 0, 1); //OK
                // 中间纵线
                LODOP.ADD_PRINT_LINE("12mm", "45mm", "36mm", "45mm", 0, 1); //1
                // 目的站右边纵线
                LODOP.ADD_PRINT_LINE("24mm", "49mm", "36mm", "49mm", 0, 1); //2


                LODOP.ADD_PRINT_TEXT("13mm", "2mm", "3mm", "11mm", "运\n单\n号"); // (Top,Left,contentWidth,contentHeight,strContent)
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 6);
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -2);

                LODOP.ADD_PRINT_TEXT("25mm", "2mm", "3mm", "11mm", "始\n发\n站");
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 6);
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -2);

                LODOP.ADD_PRINT_TEXT("25mm", "45.5mm", "3mm", "11mm", "目\n的\n站");
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 6);
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -2);

                LODOP.ADD_PRINT_TEXT("15mm", "10mm", "30mm", "10mm", obj.billId);
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 15);
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "LineSpacing", 0);


                LODOP.ADD_PRINT_TEXT("15mm", "47mm", "40mm", "10mm", obj.transportSpeciesIdName);   // (Top,Left,contentWidth,contentHeight,strContent)
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 20);
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "LineSpacing", 0);

                LODOP.ADD_PRINT_TEXT("26mm", "10mm", "30mm", "10mm", obj.cityIdName);
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 20);
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "LineSpacing", 0);

                LODOP.ADD_PRINT_TEXT("26mm", "50mm", "30mm", "10mm", obj.destCityIdName)
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 20);
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "LineSpacing", 0);


                LODOP.ADD_PRINT_TEXT("36.5mm", "1.5mm", "100mm", "4mm", "收货人:" + obj.receiveCustomerName);   // 参数 ADD_PRINT_TEXT(Top,Left,contentWidth,contentHeight,strContent)
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 7);


                LODOP.SET_PRINT_STYLEA(0,"GroundColor","#0080FF");

                // 这个二级码没有输出，要查一下
                LODOP.ADD_PRINT_BARCODE("39mm","6mm","15mm","15mm","QRCode",obj.content);
                LODOP.SET_PRINT_STYLEA(0,"QRCodeVersion",7);//设置二维码版本为7，保证二维码输出大小相同

                // “QRCodeVersion”： 设置二维码QRCode版本值，其决定容量
                // “QRCodeErrorLevel”：设置二维码QRCode纠错等级
                // “QRCodeEncodeMode”： 设置二维码QRCode编码模式

                LODOP.ADD_PRINT_TEXT("39mm", "40mm", "10mm", "5mm", obj.totalNumber); // 参数 ADD_PRINT_TEXT(Top,Left,contentWidth,contentHeight,strContent)
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 20);
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);

                LODOP.ADD_PRINT_TEXT("40mm", "50mm", "25mm", "4mm", "第 " + obj.sequence + " 件");
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);

                LODOP.ADD_PRINT_TEXT("44.5mm", "35mm", "50mm", "4mm", obj.flightNoName + " " + obj.flightDate + " " + obj.flightPlanTime);
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
                LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");

                if(index<labelData.data.length-1){
                    LODOP.NewPage();
                }
            }


            if (opType == "1") {
                LODOP.SET_PRINTER_INDEXA(selectedPrinterName)
                LODOP.PRINT(); //直接打印

            }else if (opType == "2") {
                LODOP.SET_PRINTER_INDEXA(selectedPrinterName)
                LODOP.PREVIEW(); //打印预览
            } else {
                LODOP.PRINT_SETUP(); //打印维护
            }

        }

    </script>
</body>
</html>